Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

Cannot stop a docker container

I am very new to docker. I am following a tutorial on it.

I can successfully build and run my docker container.

docker build .
docker run -p 3000:3000 3cd35580990c

But when I try to stop the container

docker stop ef485ea0dabd
Error response from daemon: cannot stop container: ef485ea0dabd: Cannot kill container ef485ea0dabda4939e7cc371408937174bf282a82e169c0fc71c2cf2b0b7bf74: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied"
: unknown

I got this long error about permission denied.

How can I solve this?

question from:https://stackoverflow.com/questions/65830921/cannot-stop-a-docker-container

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your stop command is correct if you only want the container to stop. That won't remove the container though. To remove a stopped container you should use

docker container rm <id>

If the container is running (rather than stopped) you can force its removal using

docker container rm -f <id>

You can kill and remove all containers (running and stopped) using this command:

docker container rm -f $(docker ps -qa)

To see what containers you currently have you can use:

docker ps

But that only shows running containers. If you want to see stopped containers too you can do this:

docker ps -qa

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...