Docker Community Forums

Share and learn in the Docker community.

Having trouble with ENTRYPOINT and CMD


(Mark Anders) #1

I’m having trouble getting a very simple image to run. It’s a Twisted server. Here’s the Dockerfile:

FROM python:2.7
RUN pip install --upgrade pip
RUN easy_install pyapns
RUN pip install service_identity
RUN pip install python-epoll
EXPOSE 7077
CMD ["twistd", "-r", "epoll", "web", "--class=pyapns.server.APNSServer", "--port=7077"] 
ENTRYPOINT ["/bin/sh", "-c"]

When I run it, the output is the twisted usage info, as if I had not specified the class to run, etc.

If I comment out the CMD statement and set the ENTRYPOINT to bash, if I enter the following line, it runs fine. (Note: I added the -n option simply so I can see the output. I’ve tried the above with it and it doesn’t change anything)

twistd -n -r epoll --class=pyapns.server.APNSServer --port=7077

What am I doing wrong?

Thanks!


(Alexandre) #2

There’s a good table in the Dockerfile reference that shows how CMD and ENTRYPOINT are combined:

You can also use docker inspect [OPTIONS] CONTAINER|IMAGE to check what is the command that will be executed by your container (in Config.Cmd).

HTH,
Alexandre


(Mark Anders) #3

Thank you! That helped me fix my issue.

The solution was to simply remove the ENTRYPOINT instruction. I had thought that ENTRYPOINT ["/bin/sh", "-c"] was equivalent to the default, but I guess not.

I had specified that because I had noticed that when doing docker run -i -t python:2.7, I started in a python interpreter, so so I thought (mistakenly) that I needed to override ENTRYPOINT. I hadn’t looked at the Dockerfile for that image, and had I done so I would have seen that python2 was the CMD.

Thanks again!

Mark