I got a message "docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: Error creating mount namespace before pivot: operation not permitted." when i tried to run hello-world.
I cannot find what is wrong..
[step]
- install docker desktop on windows10
- Docker version 20.10.12
docker run -it --privileged ubuntu:18.04
install docker on ubuntu:18.04
- Docker version 19.03.9
- docker run hello-world
- docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: Error creating mount namespace before pivot: operation not permitted.
CodePudding user response:
There are much easier ways to run docker commands inside a container:
- using the docker UNIX socket or what people call docker on 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!!
this does the same thing as if you run the commands from your host machine
- Run docker in docker or usually called
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:
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:
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.
