[Ubuntu]在LXC容器中使用Docker

[Ubuntu]在LXC容器中使用Docker

    • 问题
    • 问题原因
    • 解决方案
    • 结果

问题

参考docker官网指导安装后运行 sudo docker run hello-world,出现如下错误

docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "process_linux.go:368: container init caused \"rootfs_linux.go:57: mounting \\\"proc\\\" to rootfs \\\"/var/lib/docker/vfs/dir/20a621a73755db3f4030bc67bbf7ff9540bd1d63bb348d8be440d8ca63d3c922\\\" at \\\"/proc\\\" caused \\\"permission denied\\\"\"".

问题原因

容器内用户权限不足

解决方案

  1. 停止容器 lxc stop ContainerName
  2. 添加权限 lxc config set ContainerName security.nesting true
  3. 启动容器 lxc start ContainerName

结果

ubuntu@dinosaur:~$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

你可能感兴趣的:(docker,ubuntu,linux)