I believe the difference might be because the second command does shell processing while the first does not. Per the official documentation, there are the exec
and shell
forms. Your first command is an exec
form. The exec
form does not expand environment variables while the shell
form does. It is possible that by using the exec
form the command is failing due to its dependence on shell processing. You can check this by running docker logs CONTAINERID
Your second command, the shell form, is equivalent to –
CMD /etc/init.d/nullmailer start ; /usr/sbin/php5-fpm
Excerpts from the documentation –
Note: Unlike the shell form, the exec form does not invoke a command shell. This means that normal shell processing does not happen. For example,
CMD [ "echo", "$HOME" ]
will not do variable substitution on$HOME
. If you want shell processing then either use the shell form or execute a shell directly, for example:CMD [ "sh", "-c", "echo", "$HOME" ]
.