Create Docker Container from Errored Container
When I’m trying to “dockerize” an applciation I usually have to work through some wonkiness.
To diagnose a container that has errored out, I, obviously, look at the logs via
docker logs -f [container_name]. That is sometimes helpful. It will, at minimum tell me where I need to focus on the new container I’m going to create.
Pre-requisites to being able to build a diagnosis container:
- You need to use
ENTRYPOINTin the Dockerfile
CMDyou’ll be able to start a shell, with
ENTRYPOINTyour diagnosis container will just keep trying to run that
To create a diagnosis container, do the following:
- Check your failed container ID by
docker ps -a
- Create docker image form the container with
docker commit -m "diagnosis" [failed container id]
- Check the newly create docker image ID by
docker run -it [new container image id] sh
- this takes you into a container immediately after the error occurred.
Hope this helps someone else.