gpt4 book ai didi

docker - 如何在 CentOS7 中更改 docker daemon 根目录

转载 作者:IT老高 更新时间:2023-10-28 21:34:30 56 4
gpt4 key购买 nike

我在 CentOS7 中运行 docker。

我想将我的基本目录从 /var/lib/docker 更改为 /data/docker

我找到了 this来自官方网站的指南,但不知道如何将其应用于我的案例。

我只是在 /etc/docker/ 中创建新的 daemon.json。之后,当我尝试运行守护程序时发生错误。

follow 是 systemctl status -l docker.service.

● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-04-27 15:07:41 KST; 47s ago
Docs: https://docs.docker.com
Process: 42547 ExecStart=/usr/bin/dockerd (code=exited, status=1/FAILURE)
Main PID: 42547 (code=exited, status=1/FAILURE)

Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Starting Docker Application Container Engine...
Apr 27 15:07:41 DCSF-DEV08 dockerd[42547]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: default-ulimits
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Failed to start Docker Application Container Engine.
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Unit docker.service entered failed state.
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: docker.service failed.

那么我该如何解决这个问题?(我想知道当我在没有 /etc/docker/daemon.json 的情况下运行 systemctl start docker 时守护程序的默认设置是什么)

========= 编辑 ====================

我当前的 docker daemon.js.

{
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "",
"cgroup-parent": "",
"cluster-store": "",
"cluster-store-opts": {},
"cluster-advertise": "",
"debug": 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": "/data/docker",
"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": ""
}

我唯一改变的是graph,因为我只想改变根目录。 (我想把其他设置为默认值。default 表示与 systemctl start docker 相同的配置)

最佳答案

编辑/etc/docker/daemon.json.

只放以下内容:

{
"data-root": "/data/docker"
}

重启docker守护进程:sudo service docker restart

Json 元数据引用:daemon.json from Docker documentation

关于docker - 如何在 CentOS7 中更改 docker daemon 根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43649560/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com