I am running docker container Nginx, there are some errors in it,
- I cannot exec into the container because it is stopped, how can I exec into the stopped container.
- How to avoid the container stopping, if there exists an error in the container
Can someone help me by answering the above?
2
Answers
It seems like the normal execution within your container causes it to stop. So what you need to do is, create a container with an overridden entrypoint (the procedure/command that is executed on container startup).
A good place to start is by creating a shell instance where you can look around, and maybe even execute the same command manually for debugging purposes.
So let’s say I have an image
testimage:latest
that on startup executes/bin/my_script.sh
, which fails.I can then start a container with a shell instance
$ docker run --entrypoint sh -it testimage:latest
And within that container I can run the script, and check the output
in_container$ /bin/my_script.sh