Docker – How to override CMD when running a docker image

docker

I want to inspect a docker image created by someone else with both an entrypoint and cmd specified, for example:

ENTRYPOINT ["/usr/sbin/apache2ctl"]
CMD ["-D", "FOREGROUND"]

I currently do:

docker run --interactive --tty --entrypoint=/bin/bash $IMAGE --login

Is there a way to override CMD to be empty (so I don't have to use "–login") ?

Best Answer

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.