Docker: How to Enter the Closed Container and View the Logging

During the development process, especially when debugging the code, there will always be a situation where the Dockerfile or application exception causes the application to fail to start.
At this point, you want to go inside the container and see what’s going on.
At this time, I want to use docker exec -it Container_name bash it to enter the container normally, but Error response from daemon: Container baa1e5…… is not runningan exception will occur.


View the container ID that needs to be entered

# View all container processes
docker ps -a 
# Copy the ID of this unbootable container

Save the abnormally started container as an image

# Here is a random mirror name
docker commit baa1e5 temp/test

Start a new container to view the log of the startup process

docker run -it temp/test sh

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *