内容目录
参考文章
https://blog.csdn.net/qq_42957435/article/details/128081862
我的是centos7的docker 使用教程并不能成功 有些不一样 记录一下(我docker 版本1.13)
我采用的是修改docker配置的方案
教程说的是
systemctl stop docker
mkdir -p /data1/docker/lib/
rsync -r -avz /var/lib/docker /data1/docker/lib/
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --graph=/data1/docker/lib/docker
本来是另起一行加ExecStart=/usr/bin/dockerd –graph=/data1/docker/lib/docker
报错
centos是/usr/bin/dockerd-current最后修改我的docker.service文件内容为 加一行–graph=/data1/docker/lib/docker
[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=/data1/docker/lib/docker \
--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
重载启动查看镜像容器都正常
systemctl daemon-reload
systemctl restart docker
docker info
docker images
docker ps
后面因为构建需要用到docker新版本,然后就进行了升级,升级到了24.0.2
docker 1.13升级最新版docker教程参考:https://huaweicloud.csdn.net/63311c4dd3efff3090b5270d.html
因为版本高了graph参数已经删除使用data-root参数 官方文档 https://docs.docker.com/engine/deprecated/
启动之前修改 vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://mirror.aliyuncs.com"],
"data-root": "/data1/docker/lib/docker",
"log-driver":"json-file",
"log-opts": {"max-size":"100m"}
}
或者修改vim /usr/lib/systemd/system/docker.service (方案任选其一,都填写启动报错)
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --data-root="/data1/docker/lib/docker
重载启动
systemctl daemon-reload
systemctl start docker
近期评论