Dockerコマンド、Dockerfile・Compose file リファレンス

Docker-Composeファイル環境変数フォーマット

.env ファイルで docker-compose.yml 内の変数を定義できますが、その書式は以下の通りです。

Both $VARIABLE and ${VARIABLE} syntax are supported. Additionally when using the 2.1 file format, it is possible to provide inline default values using typical shell syntax:

  • ${VARIABLE:-default} evaluates to default if VARIABLE is unset or empty in the environment.
  • ${VARIABLE-default} evaluates to default only if VARIABLE is unset in the environment.

Similarly, the following syntax allows you to specify mandatory variables:

  • ${VARIABLE:?err} exits with an error message containing err if VARIABLE is unset or empty in the environment.
  • ${VARIABLE?err} exits with an error message containing err if VARIABLE is unset in the environment.

deploy

Added in version 3 file format.

Specify configuration related to the deployment and running of services. This only takes effect when deploying to a swarm with docker stack deploy, and is ignored by docker-compose up and docker-compose run.

version: "3.9"
services:
  redis:
    image: redis:alpine
    deploy:
      replicas: 6
      placement:
        max_replicas_per_node: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure

deploydocker-compose up -d コマンドでは無効となります。

docker buildx ビルドの拡張機能

Working with Docker Buildx

Reference

クロスプラットフォームでビルド

$ docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag xxx/nginx-proxy:1.21-alpine