安装docker并指定安装目录
安装docker指定安装目录的两种方式
一、第一种方式:指定docker的安装目录
二、第二种方式:使用软连接的方式
第一种方式:指定docker的安装目录
mkdir /etc/docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://qj799ren.mirror.aliyuncs.com","https://4c99aa72f1a643edb02b13b93fec6a17.mirror.swr.myhuaweicloud.com"],
"graph":"/opt/docker"
}
EOF
yum install yum-utils -y
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker containerd.io
systemctl daemon-reload
systemctl enable docker && systemctl start docker
docker info
第二种方式:使用软连接的方式
1.首先安装docker
yum install yum-utils -y
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker containerd.io
systemctl daemon-reload
systemctl enable docker && systemctl start docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://qj799ren.mirror.aliyuncs.com","https://4c99aa72f1a643edb02b13b93fec6a17.mirror.swr.myhuaweicloud.com"],
"insecure-registries": ["0.0.0.0/0"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
systemctl restart docker
systemctl status docker
ls /var/lib/docker
mv /var/lib/docker /opt/docker
ln -s /opt/docker /var/lib/docker
systemctl start docker
docker info
cd /var/lib/docker
du -sh
docker 卸载
yum list installed | grep docker
systemctl stop docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo yum remove docker-ce \
docker-ce-cli \
docker-compose-plugin \
containerd.io
apt list --installed | grep docker
apt-get remove docker-ce \
docker-ce-cli \
docker-compose-plugin \
containerd.io
apt-get remove docker \
docker-ce \
docker-ce-cli \
containerd.io