Docker安装及配置家目录

Docker安装及配置家目录

安装依赖

1
yum install -y yum-utils device-mapper-persistent-data lvm2

安装下载源

1
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

1
yum -y install docker-ce

创建目录

1
mkdir /home/dockerfile

修改默认目录

1
vim /usr/lib/systemd/system/docker.service
1
ExecStart=/usr/bin/dockerd --data-root /home/dockerfile -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock

image-20230922091045420

启动docker

1
2
3
systemctl  daemon-reload 
systemctl start docker.service
systemctl enable docker.service

若无法启动则修改 –data-root 为–graph

1
ExecStart=/usr/bin/dockerd --graph /home/dockerfile -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock

再起重启docker

1
2
3
systemctl  daemon-reload 
systemctl start docker.service
systemctl enable docker.service