Dockerfile – CMD does not run the shell script

Ok just learning about creating a Dockerfile and my understanding (which is probably wrong) is that the CMD command should be able to run a shell script from within the container once it is placed there.

I am just trying it out with a vanilla apache2 install

  • Docker: build using git push instead of ADD . /myapp
  • Modify NODE_ENV accordingly
  • Deploy .war on tomcat Docker container
  • Docker Linking in C# - What is best way to discover Environmental Variables Injected Through Linking
  • how to pass command line arguments to a python script running in docker
  • How can I make my dockerized Go program to use a dockerized Redis on default port?
  • Dockerfile

    FROM ubuntu:latest
    ADD /Scripts/
    RUN chmod +x /Scripts/
    CMD [/Scripts/]
    RUN echo "Hope this worked!"

    I have also tried this:

    CMD ["/Scripts/"]

    When I use the RUN command it works (without the [ and ])

    So I am a bit lost what the CMD is suppose to do.

    I followed the instructions from
    and read through the docker docs as well.

    How am I using the CMD wrong and how should I use it in this scenario?

  • Get CPU/Memory percentage of a docker machine
  • boot2docker: what does poweroff do to all my docker containers?
  • “correct” way to manage database schemas in docker
  • “$ docker build -t docker-whale .” throws an error saying “Some index files failed to download. They have been ignored or old ones used instead.”
  • Docker commands do not respond anymore
  • Access Host redis database from docker conatiner
  • One Solution collect form web for “Dockerfile – CMD does not run the shell script”

    • RUN is executed while you are building an image. This is usually used to install things or perform modifications in the resulting image.
    • CMD is executed when the container is started. Use this to e.g. start applications.

    Also check the docs

    The main purpose of a CMD is to provide defaults for an executing
    container. These defaults can include an executable, or they can omit
    the executable, in which case you must specify an ENTRYPOINT
    instruction as well.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.