docker启动container异常:mounting cgroup to rootfs /var/lib/docker/aufs/mnt/a64c92be709 at /sys/fs/cgroup


Step1 docker 版本:v1.12.5
[ligy@ligy-pc Desktop]$ docker info                                                 
Containers: 20
 Running: 0
 Paused: 0
 Stopped: 20
Images: 3
Server Version: 1.12.5
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 74
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local nvidia-docker
 Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 5.3.18-1-MANJARO
Operating System: Manjaro Linux
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.65 GiB
Name: ligy-pc
ID: IMFB:BEN2:JZTV:HXO7:YFJ5:LDGB:O43B:XAGX:WXMI:33UP:5V2E:P26N
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

Step2 启动docker的"hello-world"镜像
异常日志:
➜  Desktop docker run -it fce289e99eb9
docker: Error response from daemon: invalid header field value 
"oci runtime error: container_linux.go:247: starting container process caused \"
process_linux.go:359: container init caused \\\"
rootfs_linux.go:53: mounting \\\\\\\"cgroup\\\\\\\" to rootfs \\\\\\\"/var/lib/docker/aufs/mnt/ff2ef389461e428851008757ae408d7d246f9280218798b5286d3f6747a5e6f2\\\\\\\" 
at \\\\\\\"/sys/fs/cgroup\\\\\\\" caused \\\\\\\"no subsystem for mount\\\\\\\"\\\"\"\n".

异常日志

异常日志提示:
未挂载"/sys/fs/cgroup"目录。

博主测试发现,容器必须挂载"/sys/fs/cgroup"目录(无论是否有文件需要共享),
挂载其他目录不行,否则都会提示启动容器失败。

Step3 解决方案:docker容器挂载"/sys/fs/cgroup"目录
解决方案:
	docker容器挂载"/sys/fs/cgroup"目录,其中
	"/data/docker-images"是宿主机的目录,
	"/sys/fs/cgroup"是docker容器的目录

[ligy@ligy-pc Desktop]$ docker run -it -v /data/docker-images:/sys/fs/cgroup hello-world

# 输出了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/

Step4 docker启动参数的含义
docker参数含义:
  -t, --tty                         Allocate a pseudo-TTY
  -i, --interactive                 Keep STDIN open even if not attached
  -v, --volume value                Bind mount a volume (default [])
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值