该脚本需要置于 /root/workspace/docker/deb/ 下才可以生效
#!/bin/bash
downloadDeb(){
[[ -f "${1?filepath}" ]] || wget ${2?url} -P ${3?ppath} -O ${4?filename}
}
dbkgDeb(){
dpkg -i ${1?filepath}
}
debPPath="/root/workspace/docker/deb"
dockerceDebName="dockerce.deb"
dockerceCliDebName="dockerceCli.deb"
containerIODebName="container.io.deb"
dockerceDebPath="$debPPath/$dockerceDebName"
dockerceCliDebPath="$debPPath/$dockerceCliDebName"
containerIODebPath="$debPPath/$containerIODebName"
mkdir -p $debPPath
apt-get update
downloadDeb $dockerceDebPath https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_19.03.9~3-0~ubuntu-xenial_amd64.deb $debPPath $dockerceDebName
downloadDeb $dockerceCliDebPath https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce-cli_19.03.9~3-0~ubuntu-xenial_amd64.deb $debPPath $dockerceCliDebName
downloadDeb $containerIODebPath https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/containerd.io_1.2.6-3_amd64.deb $debPPath $containerIODebName
kill -9 $(lsof /var/lib/dpkg/lock-frontend |awk 'NR>1{print $2}');rm /var/lib/dpkg/lock-frontend;rm /var/lib/dpkg/lock;dpkg --configure -a
dbkgDeb $containerIODebPath &&
dbkgDeb $dockerceCliDebPath &&
dbkgDeb $dockerceDebPath