Operating System: Ubuntu 18.04.6 LTS
Kernel: Linux 4.15.0-169-generic
Architecture: x86-64
Install Docker#
If it already exists, remove the old version#
root@ubuntu:~# apt-get remove docker docker-engine docker.io containerd runc
Get the latest software source#
root@ubuntu:~# apt-get update
Install apt dependencies#
root@ubuntu:~# apt-get -y install apt-transport-https ca-certificates curl software-properties-common
Install GPG certificate#
root@ubuntu:~# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Verify#
root@ubuntu:~# apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <[email protected]>
sub rsa4096 2017-02-22 [S]
Set up stable version repository#
root@ubuntu:~# add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
Install Docker Engine-Community#
Docker is divided into three versions: Docker Engine - Community, Docker Engine - Enterprise, and Docker Enterprise. Community is the ideal choice for individual developers and small teams who want to start using Docker and try container-based applications. Docker Engine - Enterprise is designed for enterprise development of container runtimes, taking into account security and enterprise-level SLAs. Docker Enterprise is designed for enterprise development and IT teams who can build, deliver, and run critical business applications on a large scale.
-
Install the latest version
root@ubuntu:~# apt-get install docker-ce docker-ce-cli containerd.io
-
Install a specific version
apt-cache madison docker-ce sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
Verify#
root@ubuntu:~# docker -v
Docker version 20.10.21, build baeda1f
Configure user to group#
sudo usermod -aG docker <YOUR_USER>
Uninstall#
Remove installation packages#
root@ubuntu:~# apt-get autoremove docker docker-ce docker-engine docker.io containerd runc
Remove related configuration files#
root@ubuntu:~# dpkg -l | grep docker
root@ubuntu:~# dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
Uninstall related plugins#
root@ubuntu:~# apt-get autoremove docker-ce-*
Remove related configurations#
root@ubuntu:~# rm -rf /etc/systemd/system/docker.service.d
root@ubuntu:~# rm -rf /var/lib/docker
Query related software packages#
root@ubuntu:~# dpkg -l | grep docker
root@ubuntu:~# apt remove --purge xxx
Verify#
root@ubuntu:~# docker -v
Command 'docker' not found, but can be installed with:
apt install docker.io
please ask your administrator.
Install on foreign servers#
Uninstall the current version#
$ sudo apt-get remove docker docker-engine docker.io
$ sudo apt-get purge docker-ce docker-ce-cli containerd.io
$ sudo apt autoremove
$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd
Install (official website)#
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install the engine (default latest version)#
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Find the corresponding version for installation#
$ apt-cache madison docker-ce

Tips:
Ubuntu 16.04 = Ubuntu-xenial
Ubuntu 18.04 = Ubuntu-bionic
Ubuntu 20.04 = Ubuntu-focal
Choose the corresponding version 5:20.10.6~3-0~ubuntu-focal
$ sudo apt-get install docker-ce=5:20.10.6~3-0~ubuntu-focal docker-ce-cli=5:20.10.6~3-0~ubuntu-focal containerd.io