echo “remove $ditem success”
done

3、删除容器镜像:

rm -rf /var/lib/docker
echo “remove docker success”

安装Docker-cker-CE

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

增加最新版本的Docker安装仓库

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

安装Docker-CE版本

yum -y install docker-ce

启动docker

systemctl enable docker

允许开机启动

systemctl start docker
mkdir -p /etc/docker
 tee /etc/docker/daemon.json <<-‘EOF’
 {
   “registry-mirrors”: [“https://6csf38x3.mirror.aliyuncs.com”]
 }
 EOF

重启docker

systemctl daemon-reload
systemctl restart docker

jar包通过dockerfile打docker镜像

docker build -f ./Dockerfile -t dcxt .

运行刚才打包的镜像

docker run --name dcxt -u root   -d   -p 9021:9021  dcxt

#!/bin/sh
# 1、查看安装过的docker:
dockerlist=`yum list installed | grep docker`
dlength=${#dockerlist[@]}
ditem=${dockerlist[0]}
# 2、卸载docker:
#for loop
for ditem in ${dockerlist[@]}
do
    echo `yum remove -y ${ditem}`
    echo "remove $ditem success"
done
# 3、删除容器镜像:
rm -rf /var/lib/docker
echo "remove docker success"

# 安装Docker-cker-CE
yum install -y yum-utils device-mapper-persistent-data lvm2

# 增加最新版本的Docker安装仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 
        
# 安装Docker-CE版本
yum -y install docker-ce

# 启动docker
systemctl enable docker

# 允许开机启动
systemctl start docker