Useful Docker commands

Debug a stopped container, or open a shell into one

Since Docker doesn’t allow a container’s entrypoint being modified, we need to create a new container on the same image, and modify entrypoint to be a shell. One can use the command below to shell into a Docker image to examine contents, or to debug the image.

docker run -it --entrypoint sh node:10-alpine

Replace the image name, node:10-alpine with the correct image name. Shell here is sh, which is available in Alpine images, but you can change it with any other command as well.

Comments