1

I try to clear my current docker containers, but I got permission denied errors :

usernam2@ubuntuOS:/ProjectPath/DOCKER$ docker rm $(docker ps -a -q)
9790e408ff40
Error response from daemon: You cannot remove a running container a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38. Stop the container before attempting removal or force remove
usernam2@ubuntuOS:/ProjectPath/DOCKER$ docker-compose down --remove-orphans
Stopping lar_nginx_web ... error

ERROR: for lar_nginx_web  cannot stop container: a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: Cannot kill container a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied"
: unknown
Removing network docker_default
ERROR: error while removing network: network docker_default id 3f04876099e732d53f693929d90b316b269383f2b2c3a2b5f84f607992001125 has active endpoints
usernam2@ubuntuOS:/ProjectPath/DOCKER$ docker system prune --force --volumes
Total reclaimed space: 0B


usernam2@ubuntuOS:/ProjectPath/DOCKER$ docker ps
CONTAINER ID   IMAGE        COMMAND                  CREATED          STATUS          PORTS      NAMES
a74d9ad73c26   docker_app   "docker-php-entrypoi…"   13 minutes ago   Up 13 minutes   9000/tcp   lar_nginx_web


usernam2@ubuntuOS:/ProjectPath/DOCKER$ docker-compose down
Stopping lar_nginx_web ... error

ERROR: for lar_nginx_web  cannot stop container: a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: Cannot kill container a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied"
: unknown
Removing network docker_default
ERROR: error while removing network: network docker_default id 3f04876099e732d53f693929d90b316b269383f2b2c3a2b5f84f607992001125 has active endpoints

I suppose I have no tio run them as root, but even running asroot I got the same errors .

How can it be fixed ?

Thanks!

Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91

2 Answers2

0

you have to either kill/stop all the running containers before removing them. It can be killed/stopped via running the cmd below

docker kill $(docker ps -q)

         or

docker stop $(docker ps -aq)

and then remove them via

docker rm $(docker ps -a -q)
  • I have the same error : docker kill $(docker ps -q) Error response from daemon: Cannot kill container: a74d9ad73c26: Cannot kill container a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied" : unknown Maybe I have to add some access to my ubuntu user(not root ) – Petro Gromovo Sep 03 '21 at 14:40
  • try `sudo docker kill $(docker ps -q)` – prakash sellathurai Sep 03 '21 at 14:41
  • I got : sudo docker kill $(docker ps -q) Error response from daemon: Cannot kill container: a74d9ad73c26: Cannot kill container a74d9ad73c264c800c3628738c0f4b62f187aa51c7f93cbfc539494903a72f38: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied" : unknown – Petro Gromovo Sep 03 '21 at 14:47
  • I restarted OS : did not help. Maybe some internal error? If there is a way to reinit docker ? – Petro Gromovo Sep 03 '21 at 15:01
  • if docker always restarts even when you stopped it then chances are that you enabled `--restart=always`.if that's a case this might solve your question [https://stackoverflow.com/questions/39072357/how-to-stop-a-docker-container-which-started-with-restart-always](https://stackoverflow.com/questions/39072357/how-to-stop-a-docker-container-which-started-with-restart-always) – prakash sellathurai Sep 03 '21 at 15:13
0

It can be related to AppArmor. Check if you have multiple docker instances installed from different sources as it can result with conflicting AppArmor profiles.

As I can see you are using Ubuntu - so it's possible that you have additional docker provided via snap.

MiS27
  • 1