I have a simple Dockerfile that doesnt seem to be executing the CMD command.
#Expose port 80
#Start nginx server
#RUN service nginx start
COPY startup_nginx.sh /startup_nginx.sh
RUN chmod +x /startup_nginx.sh
It turns out that I need double quotes instead of single like this.
This is not explicit in the docs and seems like something basic that should be spelled somewhere as there are no error messages. It fails silently which makes it extremely hard to debug as the startup script is what is needed to create a running process so the container doesnt exit.
Note: there is issue 5701 requesting for making a docker build error when single quotes are used in JSON expressions like ENTRYPOINT or CMD.
PR 8486 is supposed to resolve this, but it only add a test case, not the actual error itself.
It does explain the problem though:
This testcase is supposed to generate an error because the JSON array we're passing in on the CMD uses single quotes instead of double quotes (per the JSON spec).
This means we interpret it as a "string" instead of "JSON array" and pass it on to "sh -c" and it should barf on it
Asked in February 2016Viewed 2,723 timesVoted 10Answered 2 times