How can I override CMD when running a docker image?

You could just enter via docker run -it --entrypoint=/bin/bash $IMAGE -i (you ‘ll launch a new container from the image and get a bash shell in interactive mode), then run the entrypoint command in that container.

You can then inspect the running container in the state it should be running.

EDIT: Since Docker 1.3 you can use exec to run a process in a running container. Start your container as you ‘d normally do, and then enter it by issuing:

docker exec -it $CONTAINER_ID /bin/bash

Assuming bash is installed you will be given shell access to the running container.

Leave a Comment