How to put command of build docker container to dockerfile?

Even if @mchawre’s answer seems to directly answer OP’s question “syntactically speaking” (as a Dockerfile was asked), a docker-compose.yml is definitely the way to go to make a docker run command, as custom as it might be, reproducible in a declarative way (YAML file).

Just to complement @ChrisBecke’s answer, note that the writing of this YAML file can be automated. See e.g., the FOSS (under MIT license) https://github.com/magicmark/composerize

FTR, the snippet below was automatically generated from the following docker run command, using the accompanying webapp https://composerize.com/:

docker run -it -p 4000:4000 bitgosdk/express:latest

version: ‘3.3’ services: express: ports: – ‘4000:4000’ image: ‘bitgosdk/express:latest’

I omitted the CMD arguments –disablessl -e test on-purpose, as composerize does not seem to support these extra arguments. This may sound like a bug (and FTR a related issue is opened), but meanwhile it might just be viewed as a feature, in line of @DavidMaze’s comment

Leave a Comment

Your email address will not be published. Required fields are marked *