Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pass arguments to a pre-built docker image through docker compose

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So far I have

ganache:
  network_mode: 'host'
  image: "trufflesuite/ganache-cli:latest"

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading