From https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository



1. Update the apt package index:
sudo apt-get update


2. Install packages to allow apt to use a repository over HTTPS:
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common


3. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –


4.Use the following command to set up the stable repository.
sudo add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable”


5.Update the apt package index.
sudo apt-get update


6.Install the latest version of Docker CE
sudo apt-get install docker-ce



或者直接使用Docker 提供的脚本安装。
1. curl -fsSL get.docker.com -o get-docker.sh
2. sudo sh get-docker.sh