因为yum安装的docker主目录在/var/lib/docker一般这个目录空间都不是很多,所以,如果打算长期使用且项目多的话,建议将主目录迁移至其他空间足够大的磁盘中。
第一步:停止docker服务
[root@az1-share-dev-cicd-02 /]# systemctl stop docker
第二部:修改docker.service文件
[root@az1-share-dev-cicd-02 multi-user.target.wants]# pwd /etc/systemd/system/multi-user.target.wants [root@az1-share-dev-cicd-02 multi-user.target.wants]# vim docker.service [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker #ExecStart=/usr/bin/dockerd ###默认的配置 ExecStart=/usr/bin/dockerd --graph /volumes/docker ###修改后的在这里 就是在默认配置后面追加 --graph +指定存放的路径 ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
第三步:重新注册docker
[root@az1-share-dev-cicd-02 /]# systemctl disable docker [root@az1-share-dev-cicd-02 /]# systemctl enable docker [root@az1-share-dev-cicd-02 /]# systemctl daemon-reload [root@az1-share-dev-cicd-02 /]# systemctl start docker
第四步:查看docker 配置信息
[root@az1-share-dev-cicd-02 /]# docker info #次数省略一万字 Docker Root Dir: /volumes/docker ###此处显示为修改后的路径就成功啦 #次数省略一万字
最后建议pull一个镜像试试,查看一下镜像是否存放到了你的目录里面。