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?
CodePudding user response:
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
CodePudding user response:
- I cannot exec into the container because it is stopped, how can I exec into the stopped container.
No, you cannot exec onto a stopped container, you'd need to start the container up again before being able to exec onto it.
- How to avoid the container stopping, if there exists an error in the container
As far as I am aware there is nothing to prevent a container stopping when there are errors, however I have found How to prevent a container from shutting down during an error? which might help you with what you need (please give them credit if it does work).