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
ENTRYPOINT
andCMD
for being able to execute commands. These also can be used in conjunction, but in this case theENTRYPOINT
will be the command what we want to execute and theCMD
will represent some default arguments for theENTRYPOINT
(docs).For example:
The
--argumentB=valB
will be appended to thejava -jar app.jar --argumentA=valA
, if we run the image like this:But the
CMD
part will be overridden if we provide other arguments when we run the docker image:Also, we can commit the
CMD
and have theENTRYPOINT
only, if we don't require some defaults to be appended to theENTRYPOINT
.