因为对docker了解不是深入(不是开发docker)。但把docker的配置文件研究透彻,会起到“事半功倍”的效果。下面只是随笔记一下,不能成为博客,若以后有深入研究,再详细整理。
一、问题集锦
【问题1 一个已经停止的容器,再次启动报Unknown runtime specified docker-runc】
[root@localhost ~]# docker start 389fcaab1ca4
Error response from daemon: Unknown runtime specified docker-runc
Error: failed to start containers: 389fcaab1ca4
[root@localhost ~]#
解决方法:
[root@localhost containers]# vi /var/lib/docker/containers/容器ID/hostconfig.json
修改里面"Runtime":"docker-runc",修改为"Runtime":"runc"
原因:不详。
【问题2 Device is Busy delete container(25f59daf0cda) failed.】
[root@localhost]#docker rm 25f59daf0cda
Error response from daemon: Driver devicemapper failed to remove root filesystem 25f59daf0cdaa93a204e3033cc6bfd1e836aab978138962029e2bd938241c626: Device is Busy
delete container(25f59daf0cda) failed.
[root@localhost]#
定位过程:
通过docker ps 查看容器状态是Dead状态(如果是Eixt状态应该可以正常删除),
[root@localhost]#docker ps -a | grep 25f59daf0cda
25f59daf0cda nginx "/opt/startup" 7 days ago Dead nginx-110112
[root@localhost]#
参考此网站: https://blog.terminus.io/docker-device-is-busy/
【配置集锦】
用户级配置文件:
/etc/docker/daemon.json(没有则自己创建)
daemon.json样例:
{
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "", /* 指定网桥 */
"cgroup-parent": "",
"cluster-store": "",
"cluster-store-opts": {},
"cluster-advertise": "",
"debug": true, /* 日志级别 如果是true则打印详细日志信息 */
"default-gateway": "",
"default-gateway-v6": "",
"default-runtime": "runc",
"default-ulimits": {},
"disable-legacy-registry": false,
"dns": [],
"dns-opts": [],
"dns-search": [],
"exec-opts": [],
"exec-root": "",
"fixed-cidr": "",
"fixed-cidr-v6": "",
"graph": "",
"group": "",
"hosts": [],
"icc": false,
"insecure-registries": [],
"ip": "0.0.0.0",
"iptables": false,
"ipv6": false,
"ip-forward": false,
"ip-masq": false,
"labels": [],
"live-restore": true,
"log-driver": "",
"log-level": "",
"log-opts": {},
"max-concurrent-downloads": 3,
"max-concurrent-uploads": 5,
"mtu": 0,
"oom-score-adjust": -500,
"pidfile": "",
"raw-logs": false,
"registry-mirrors": [],
"runtimes": {
"runc": {
"path": "runc"
},
"custom": {
"path": "/usr/local/bin/my-runc-replacement",
"runtimeArgs": [
"--debug"
]
}
},
"selinux-enabled": false,
"storage-driver": "",
"storage-opts": [],
"swarm-default-advertise-addr": "",
"tls": true,
"tlscacert": "",
"tlscert": "",
"tlskey": "",
"tlsverify": true,
"userland-proxy": false,
"userns-remap": ""
}
系统级配置文件:
/lib/systemd/system/docker.service ---> 启动服务脚本:systemctl start docker 命令就是调用此配置文件