Install Docker Engine on Ubuntu (x86_64/amd64)
Uninstall old versions
Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
Install using the repository
Set up the repository
- Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
- Add Docker’s official GPG key.
official and USTC repository are listed, choose ONE you like.
- official
# official source
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
- USTC
# ustc mirror
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install Docker Engine
Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
set chinese hub mirror
# make /etc/docker folder
$ sudo mkdir -p /etc/docker
# make daemon.json file in /etc/docker folder and write your mirrors
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
# You can also chose other mirrors as you like by replacing the https link in the
# spuare brackets, or sign up a aliyun ID to get a personal accelerator