Suppose we have a Dockerfile with some CMD and we produced and image from it. Now suppose that we write a docker-compose and one of the services is built from that image.
What I want to do is running the same command but concatenating my own new parameters.
As an example, suppose the original CMD is
java -jar app.jar --argumentA=valA
I want the command to be
java -jar app.jar --argumentA=valA --argumentB=valB
Is it possible?
I'm not entirely sure if this is what you would want to accomplish, but...
Dockerfile exposes both
ENTRYPOINTandCMDfor being able to execute commands. These also can be used in conjunction, but in this case theENTRYPOINTwill be the command what we want to execute and theCMDwill represent some default arguments for theENTRYPOINT(docs).For example:
The
--argumentB=valBwill be appended to thejava -jar app.jar --argumentA=valA, if we run the image like this:But the
CMDpart will be overridden if we provide other arguments when we run the docker image:Also, we can commit the
CMDand have theENTRYPOINTonly, if we don't require some defaults to be appended to theENTRYPOINT.