Docker CMD evaluation with ENTRYPOINT Docker CMD evaluation with ENTRYPOINT docker docker

Docker CMD evaluation with ENTRYPOINT


Yes. This is exactly how it is supposed to work.

The value of CMD is just passed as a parameter to the ENTRYPOINT.

Main difference between CMD and ENTRYPOINT is that CMD just provides default command argument to the ENTRYPOINT program and it's usually overridden by the arguments to run command. On the other hand you have to redefine ENTRYPOINT explicitly with --entrypoint option if you want different command to be executed.

Also, notice there is a difference how things are executed depending on the way ENTRYPOINT and CMD are defined in the Dockerfile. When they are defined as an array in the form of ['arg1', 'arg2'] this array is passed as is to the ENTRYPOINT command, with the first element of ENTRYPOINT being the program being executed. In the other case when they are defined as a simple string like arg1 arg2 this string is first passed is prepended by "/bin/sh -c" note that Docker does not execute /bin/sh and returns the result of evaluation back, that string itself is passed to the ENTRYPOINT program.

So in your case you have to use array method of passing the arguments:

CMD  [-ip, $EXTERNAL_IP,  consul://$CONSUL_HOST]