为什么我不能在ubuntu上移除正在运行的docker容器?



我试图清除我当前的docker容器,但我得到了权限拒绝错误:

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

我想我没有以root身份运行它们,但即使以root身份运行,我也会得到相同的错误。

如何修复?

谢谢!

您必须在删除它们之前杀死/停止所有正在运行的容器。可以通过运行

下面的cmd命令来终止/停止它。
docker kill $(docker ps -q)
or
docker stop $(docker ps -aq)

,然后通过

删除
docker rm $(docker ps -a -q)

可能与AppArmor有关。检查您是否从不同的来源安装了多个docker实例,因为这可能导致冲突的AppArmor配置文件。

我可以看到你使用的是Ubuntu——所以你有可能通过snap提供了额外的docker。

相关内容

  • 没有找到相关文章

最新更新