What are docker compose args and what do they do
The docker-compose.yml file is a YAML configuration file that can define services and configure the Docker environment of your project. The following is an example of a docker-compose.yml file:
version: “3”
services:
db: “mysql”
webfront : build : ./web/ – tarball-size=18G web frontend volumes : – ./web/data:/var/www/html
ports: – “80” : containerPort – “443” : containerPort environment: [“DB_NAME=mysql”, “DB_USER=root”, “DB.HOST=db”, “DB_PORT=3306”, “DB_PASSWORD=root”]
The docker-compose.yml file is a YAML configuration file that can define services and configure the Docker environment of your project. The following is an example of a docker-compose.yml file:
version : ‘ 3’ services : web : build : ./web/ – tarball-size = 18G web frontend volumes : – . /web/data:/var/www/html ports : – “80” : containerPort – “443” : containerPort environment : [“DB_NAME=mysql”, “DB_USER=root”, “DB.HOST=db”, “DB_PORT=3306”, “DB_PASSWORD=root”]
How to use them in your docker-compose file
To pass a value to a configuration option, use the key=value syntax. For example, if you have a network in your docker-compose file and you want to set the driver option to overlay , you have to write driver=overlay . If you want to pass multiple options, separate them with spaces.
If your configuration key contains a special character, such as a space, use quotes. For example, if you have a network in your docker-compose file and you want to set the driver option to overlay , you have to write driver=”overlay” .
For an environment variable that uses the syntax $VARIABLE_NAME , use this syntax: ${VARIABLE_NAME} . This applies to all environment variables except for docker-compose’s own variables.
If you need double quotes in the configuration file, write $VARIABLE_NAME” . For example, if you have a network in your docker-compose file and you want to set the driver option to overlay , you have to write driver=”overlay” .
You can also use — for a value that is an optional argument. For example, if you want to add an argument to your docker-compose run command, use –COMPOSE_FILE=” $ ./docker-compose.yml ” .
If you want to use an environment variable for an argument value, for example –COMPOSE_FILE , use this syntax: –COMPOSE_FILE= $ENV_VARIABLE/compose.yml . This works even in options that require a value (like driver ).
