I am trying to use docker-compose up
the way you can use docker run [APP_CONTAINER_NAME] [APP_OPTIONS]
.
The point of Docker Compose is that you don't have to remember all your command line switches.
If you want to change environment variables for different contexts, I suggest you create a base common.yml
file for Compose. You can then create a new yml file for each different context, inheriting from the common.yml
file with the extends
instruction. You can then use the -f
flag to docker compose
to switch between contexts.
Also note that Compose should not "rebuild" anything if you just change a variable in the yml, and that you can use an external file for environment variables if that works better for you.
docker run is defined as:
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
While docker compose run
is defined as:
docker-compose run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
In both cases, the final ARGS
(which could be the "APP_OPTIONS
" of the OP's question) will be passed to the container command.
Note that some of the docker run
option can be used as is in docker-compose run
(lie a -d
, to run the container command detached), but not all of them.
You need to look at the Dockerfile and see what is handling the APP_OPTIONS. Chances are that the ENTRYPOINT is taking the option flags. In this case, specify the command to send to the entrypoint using
command: [-flag1, -flag2]
This works because the COMMAND in the Dockerfile acts as default args to the entrypoint when both are specified https://www.ctl.io/developers/blog/post/dockerfile-entrypoint-vs-cmd/
© 2022 - 2024 — McMap. All rights reserved.
docker run
and use ENTRYPOINT in my Dockerfile in order to achieve this behaviour. – Epiglottis