Docker 常见问题
- PS:0.0.0.0/0 表示信任所有非https地址的镜像仓库,对于内网测试,这样配置很方便。对于线上生产环境,
- 为了安全请不要这样配置
- touch /etc/docker/daemon.json
- {
- "storage-driver": "overlay"
- }
- EOF
- systemctl daemon-reload && systemctl restart docker
编辑 文件,并设置:GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
接着
SUSE
- grub2-mkconfig -o /boot/grub2/grub.cfg
- Update grub
Ubuntu
启动容器的时候添加:
- -e http_proxy= -e https_proxy=
- --volume=/:/rootfs:ro \
- --volume=/var/run:/var/run:rw \
- --volume=/sys:/sys:ro \
- --volume=/var/lib/docker/:/var/lib/docker:ro \
- --publish=8080:8080 \
- --detach=true \
- --name=cadvisor \
- google/cadvisor:latest
When you bind-mount /var/lib/docker/
, this effectively mounts all resources of all other running containers as filesystems within the container which mounts . When you attempt to remove any of these containers, the removal attempt may fail with an error like the following:
The problem occurs if the container which bind-mounts /var/lib/docker/
uses statfs
or on filesystem handles within /var/lib/docker/
and does not close them.
Typically, we would advise against bind-mounting /var/lib/docker
in this way. However, cAdvisor requires this bind-mount for core functionality.