Docker Community Forums

Share and learn in the Docker community.

The container based on php:5.6-apache is not running when I try to execute shell script with using CMD instruction

I have DockerFile

FROM php:5.6-apache

SHELL ["/bin/bash", "-c"]


COPY /root/

RUN chmod 700 /root/


COPY /root/

RUN chmod 700 /root/

CMD /root/ # <-- NOT WORKING (((

The image is building well.

The container is not starting if I have CMD instruction, without any logs! If I skip the CMD instruction, container is working well, BUT I need to run every time when the container run. How can I resolve this issue?


touch /root/$RANDOM-init.txt


touch /root/$RANDOM-start.txt

CMD is basically a parameter for whatever is defined as ENTRYPOINT, which itself defaults to some /bin/sh -c if not set by the base image. So, do you know what ENTRYPOINT is defined by that image? Rather than setting CMD, didn’t you intend to replace the image’s entrypoint instead?

That I don’t understand. RUN is used while building the image, not while running it using the combination of ENTRYPOINT and CMD. Are you sure you’re not running into build caching? See also Leverage build cache in the documentation.

Also, are sure you want to copy into both /root/ and /root/ That’s what you’re doing:

Also, since you’re only touching, the container will exit right efter it touches