網(wǎng)頁設計與網(wǎng)站建設完全實戰(zhàn)手冊石家莊熱搜
docker實戰(zhàn)(一):centos7 yum安裝docker
docker實戰(zhàn)(二):基礎命令篇
docker實戰(zhàn)(三):docker網(wǎng)絡模式(超詳細)
docker實戰(zhàn)(四):docker架構(gòu)原理
docker實戰(zhàn)(五):docker鏡像及倉庫配置
docker實戰(zhàn)(六):docker 網(wǎng)絡及數(shù)據(jù)卷設置
docker實戰(zhàn)(七):docker 性質(zhì)及版本選擇
認知升維: 道、法、術(shù)、器、勢
一:? 配置docker日志文件
通過??/etc/docker/daemon.json???配置Docker的??log-driver??參數(shù),遇到了Docker無法啟動的錯誤。
配置信息如下:
[root@www ~]# cat /etc/docker/daemon.json?
{
? ? "registry-mirrors": [
? ? ? ? "https://d8b3zdiw.mirror.aliyuncs.com",
? ? ? ? "https://reg-mirror.qiniu.com/",
? ? ? ? "https://hub-mirror.c.163.com/",
? ? ? ? "https://docker.mirrors.ustc.edu.cn/"
? ? ],
? ? "log-driver": "json-file",
? ? "log-opts": {
? ? ? ? "max-size": "50m",
? ? ? ? "max-file": "5"
? ? }
? ? ?
}
查看日志: journalctl -amu docker?
錯誤信息:
dockerd-current[3335]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: graph: (from flag: /data/docker
8月 18 12:02:09 www.yhchange.com systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
8月 18 12:02:09 www.yhchange.com systemd[1]: Failed to start Docker Application Container Engine.
8月 18 12:02:09 www.yhchange.com systemd[1]: Unit docker.service entered failed state.
8月 18 12:02:09 www.yhchange.com systemd[1]: docker.service failed.
8月 18 12:05:49 www.yhchange.com systemd[1]: Starting Docker Application Container Engine...
8月 18 12:05:49 www.yhchange.com dockerd-current[3446]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: data-root
8月 18 12:05:49 www.yhchange.com systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
8月 18 12:05:49 www.yhchange.com systemd[1]: Failed to start Docker Application Container Engine.
8月 18 12:05:49 www.yhchange.com systemd[1]: Unit docker.service entered failed state.
8月 18 12:05:49 www.yhchange.com systemd[1]: docker.service failed.
這個含義應該是Docker啟動的時候傳入了命令行參數(shù),同時也指定了配置文件,兩個配置發(fā)生了沖突。那么就查看一下Docker服務啟動文件。
?
二: 可以看到啟動的時候會加載EnvironmentFile=-/etc/sysconfig/docker 配置文件
[root@www ~]# cat /usr/lib/systemd/system/docker.service?
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=main
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current --graph /data/docker_data \
? ? ? ? ? --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
? ? ? ? ? --default-runtime=docker-runc \
? ? ? ? ? --exec-opt native.cgroupdriver=systemd \
? ? ? ? ? --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
? ? ? ? ? --init-path=/usr/libexec/docker/docker-init-current \
? ? ? ? ? --seccomp-profile=/etc/docker/seccomp.json \
? ? ? ? ? $OPTIONS \
? ? ? ? ? $DOCKER_STORAGE_OPTIONS \
? ? ? ? ? $DOCKER_NETWORK_OPTIONS \
? ? ? ? ? $ADD_REGISTRY \
? ? ? ? ? $BLOCK_REGISTRY \
? ? ? ? ? $INSECURE_REGISTRY \
?? ? ?$REGISTRIES
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process
[Install]
WantedBy=multi-user.target
看下配置文件信息:
cat? /etc/sysconfig/docker
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
? ? DOCKER_CERT_PATH=/etc/docker
fi# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
?
?三: 去掉配置文件中:?--log-driver=journald
?重新啟動:
?
[root@www ~]# systemctl daemon-reload
[root@www ~]# systemctl restart docker
[root@www ~]# systemctl status docker
● docker.service - Docker Application Container Engine
? ?Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
? ?Active: active (running) since 日 2023-08-20 11:38:00 CST; 9s ago
? ? ?Docs: http://docs.docker.com
?Main PID: 2160 (dockerd-current)
? ? Tasks: 32
? ?CGroup: /system.slice/docker.service
? ? ? ? ? ?├─2160 /usr/bin/dockerd-current --graph /data/docker_data --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/doc...
? ? ? ? ? ?└─2171 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --r...
8月 20 11:37:59 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:37:59.491453685+08:00" level=info msg="libcontainerd: new containerd process, pid: 2171"
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.615692314+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.617335438+08:00" level=info msg="Loading containers: start."
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.644238265+08:00" level=info msg="Firewalld running: false"
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.829163222+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set ...rred IP address"
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.883382659+08:00" level=info msg="Loading containers: done."
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.937997301+08:00" level=info msg="Daemon has completed initialization"
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.938173411+08:00" level=info msg="Docker daemon" commit="7d71120/1.13.1" graphdriver=overlay2 version=1.13.1
8月 20 11:38:00 www.yhchange.com dockerd-current[2160]: time="2023-08-20T11:38:00.954810143+08:00" level=info msg="API listen on /var/run/docker.sock"
8月 20 11:38:00 www.yhchange.com systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
?
?