简体   繁体   English

docker 中的 Docker:docker 运行 hello-world 错误操作不允许

[英]Docker in docker : docker run hello-world error operation not permitted

I got a message "docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: Error creating mount namespace before pivot: operation not permitted."我收到一条消息“docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: Error created mount namespace before pivot: operation not allowed。” when i tried to run hello-world.当我尝试运行 hello-world 时。

I cannot find what is wrong..我找不到什么问题..

[step] [步]

  1. install docker desktop on windows10在windows10上安装docker桌面
  • Docker version 20.10.12 Docker 版本 20.10.12
  1. docker run -it --privileged ubuntu:18.04 docker 运行 -it --特权 ubuntu:18.04

  2. install docker on ubuntu:18.04在 ubuntu:18.04 上安装 docker

  • Docker version 19.03.9 Docker 版本 19.03.9
  1. docker run hello-world docker 运行你好世界
  • docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: Error creating mount namespace before pivot: operation not permitted. docker:注册层失败:ApplyLayer 退出状态 1 标准输出:标准错误:在 pivot 之前创建安装命名空间时出错:不允许操作。

There are much easier ways to run docker commands inside a container:在容器内运行 docker 命令有很多更简单的方法:

  • using the docker UNIX socket or what people call docker on docker DooD :在 docker UNIX 插座或人们所说的 docker 上使用DooD
run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker ubuntu:20.04

once you run this you can try to run your docker commands it will work just fine but keep in mind!!运行此命令后,您可以尝试运行 docker 命令,它会正常工作,但请记住!

this does the same thing as if you run the commands from your host machine这与从主机运行命令的作用相同

  • Run docker in docker or usually called DinD :在 docker 或通常称为DinD
docker run -d --privileged --name docker \
    -e DOCKER_TLS_CERTDIR=/certs \
    -v docker-certs-ca:/certs/ca \
    -v docker-certs-client:/certs/client \
    docker:dind

then you can execute dood commands inside that container running:然后您可以在该容器内执行 dood 命令运行:

docker exec -it dood sh

This is a great alternative for you because it's lightweight and easy to setup!这对您来说是一个很好的选择,因为它重量轻且易于设置!

You can find more here .你可以在这里找到更多。

In case you insist to use the Ubuntu:18.04 and installing docker inside of it, I would first say you haven't specified how you installed docker it should probably work if you followed how to install Docker on a Ubuntu machine , could be some volume mounting issue aswell, you can try to run these commands once the ubuntu container is created or just use a Dockerfile : In case you insist to use the Ubuntu:18.04 and installing docker inside of it, I would first say you haven't specified how you installed docker it should probably work if you followed how to install Docker on a Ubuntu machine , could be some volume安装问题也是如此,您可以在创建 ubuntu 容器后尝试运行这些命令,或者只使用Dockerfile

apt-get update &&\
apt-get install curl &&\
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&\
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" &&\
apt-cache policy docker-ce &&\
apt-get install -y docker-ce

and then running docker commands must work properly unless you have some network issues.然后运行 docker 命令必须正常工作,除非您有一些网络问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM