Troubleshoot stopped containers

The stopped Docker containers are still available for troubleshooting. You can create an image of them and run them as new containers to inspect the log files and execute commands in them.

View the standard output of the failed container

docker logs MY_CONTAINER_ID

Run a failing container with a Bash terminal

If a container exists with an error within a few seconds, it can be beneficial to start a terminal window in it to view the log files and execute commands. We will override the entry point of the container to start a Bash terminal.

Create an image of the stopped container

docker commit MY_STOPPED_CONTAINER_ID MY_NEW_IMAGE NAME

Run the saved image as a new container and start a Bash terminal instead of the original entry point

docker run -it --entrypoint bash MY_NEW_IMAGE_NAME

Leave a comment

Leave a Reply