Where is the CMD specified in the image (if any is specified). Long story short, you can tell Docker to run the command bash, which drops you into a shell: docker run -it name-of-image bash docker run -it continuumio/miniconda3:latest bash docker run -it node:latest bash. If you specify -entrypoint bash, then instead it runs bash
So in the earlier two commands, if you run bash as the CMD, and the default ENTRYPOINT is used, then the container will be run using /bin/sh -c bash
If you (or the image) does not specify ENTRYPOINT, the default entrypoint is /bin/sh -c. In this command, you are specifying bash as the ENTRYPOINT.Įvery container is run using a combination of ENTRYPOINT and CMD. In the two commands above, you are specifying bash as the CMD. Or to enter a running container, use exec instead: docker exec -it bashĭo you know what is the difference between this and docker run -it -entrypoint bash docker/whalesay? Or to prevent the above container from being disposed, run it without -rm. To run a disposable new container, you can simply attach a tty and standard input: docker run -rm -it -entrypoint bash That's because by default, a container is non-interactive, and a shell that runs in non-interactive mode expects a script to run. If you docker run without attaching a tty, and only call bash, then bash finds nothing to do, and it exits. Why did it not work? How can I make it work? $ docker run docker/whalesay bashĬONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESħce600cc9904 docker/whalesay "bash" 5 seconds ago Exited (0) 3 seconds ago loving_mayer However, I am unable to run a shell in a container created from this image. $ docker run docker/whalesay lsb_release -a rw-r-r- 1 root root 631 pgp_public_key.txt I am able to run arbitrary shell commands in a container created from docker/whalesay image.