1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #!/bin/bash # description: Unstall Docker in ubuntu
# Define docker version docker_version=""
# Check and uninstall old version Docker(root) # apt-get remove docker docker-engine docker.io containerd runc
# Update software package(root) apt-get update
# Installing Docker Dependencies(root) apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
# Add Docker's official GPG key # Docker official: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Add Docker's software source(root) # Docker official source # sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# aliyun source add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Install Docker(root) apt-get update
# Check docker version: apt-cache madison docker-ce if [ ! -z ${docker_version} ];then apt-get install -y docker-ce=${docker_version} docker-ce-cli=${docker_version} containerd.io else apt-get install -y docker-ce docker-ce-cli containerd.io fi
# Start docker systemctl enable docker --now
|