I want to pass some arguments to a prebuilt docker image through the compose file. So, I don't have the Dockerfile and I can't use the context.
For instance, in the docker hub documentation of the ganache-cli image, there is the possibility to use the following command to run
docker run --detach --publish 8545:8545 trufflesuite/ganache-cli:latest --accounts 10 --debug
The question is, how to pass this accounts 10 through the docker compose file?
So far I have
ganache:
network_mode: 'host'
image: "trufflesuite/ganache-cli:latest"
Whatever is used after the image name in a docker run
command replaces any CMD
statement in the image and is passed to the entrypoint as parameters - or, if there is no entrypoint - just run as a command.
To have the equivalent of your docker run
command in a docker-compose file, you'd create something like this:
ganache:
image: trufflesuite/ganache-cli:latest
command: --accounts 10 --debug
ports:
- 8545:8545
Then you'd run it using docker compose up -d
or docker-compose up -d
depending on the version of compose you have installed.