I guess we have all been there trying to debug a Docker container in exited state. Without further ado here are the steps required.
Prerequisites
- Docker
Solution
Step 1. Identify the container name by running docker ps -a
to list all containers including stopped/exited ones, then copy the name. For the purpose of this example let’s say the container name value is: app-1
.
Step 2. Create a Docker image of the container state. With app-1
being based of the default CentOS image, run:
docker commit app-1 debug/centos
Step 3. At last, create a new container and run it in interactive mode:
docker run -it --rm --entrypoint sh debug/centos
alt(easier) solution: docker start -ai app-1
Conclusion
In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.