docker配置文件以及各种问题汇总---随笔

本文解答了Docker中常见的两个问题:启动已停止容器时出现未知运行时错误及删除容器时提示设备繁忙的问题,并提供了详细的解决步骤。同时,介绍了Docker配置文件daemon.json的结构及其各项参数含义。

因为对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 命令就是调用此配置文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值