參考鏈接:https://docs.docker.com/install/linux/docker-ce/ubuntu/
參考鏈接:https://blog.csdn.net/sunchaoyiA/article/details/81229961
(推薦這篇教程)阿里鏡像安裝參考鏈接:http://www.cnblogs.com/hupeng1234/p/9773770.html
1.更新ubuntu的apt源索引:
sudo apt-get update
2. 安裝包允許apt通過HTTPS使用倉庫:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
3. 添加Docker官方GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4.設置Docker穩定版倉庫:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
5.添加倉庫後,更新apt源索引:
sudo apt-get update
6.安裝最新版Docker CE(社區版):
sudo apt-get install docker-ce
7.第六步可能會報錯,錯誤如下:
8.報錯的話,執行如下命令,即安裝指定版本:
sudo apt install docker-ce=17.03.2~ce-0~ubuntu-xenial
9. 檢查Docker CE是否安裝正確:
sudo docker run hello-world
10. 出現如下信息,表示安裝成功:
11.爲了避免每次命令都輸入sudo,可以設置用戶權限,注意執行後須註銷重新登錄 :
sudo usermod -a -G docker $USER
12.祝賀你,成功安裝Docker,並且安裝完成Docker後,默認已經啓動了docker服務!!!