# step 0: clear
# sudo apt-get remove docker docker-engine docker-ce docker.io
# step 1: 安裝必要的一些系統工具sudo apt-get update
#sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安裝GPG證書
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - //官方 # curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - //阿里雲
# Step 3: 寫入軟件源信息
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" //官方 # sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" //阿里雲
# Step 4: 更新並安裝Docker-CE # sudo apt-get -y update # sudo apt-get -y install docker-ce
# 此處默認安裝的是docker最新版本,但由於WSL的問題,可能會存在問題,會在拉取鏡像的時候出現錯誤:Error response from daemon: OCI runtime create failed context canceled
# 所以我們安裝指定的docker版本,見4.1,我安裝的是18.03.1-ce # Step 4.1 安裝指定版本的Docker-CE: # Step 4.11: 查找Docker-CE的版本: # apt-cache madison docker-ce # docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages # docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages # Step 4.1.2: 安裝指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial) # sudo apt-get -y install docker-ce=[VERSION]
# Step 5: 查看docker的版本
# docker -v
# Step 6: 查看docker的啟動狀態
# sudo service docker status
# Step 7:啟動docker
# sudo service docker start //備注:WSL目前是WSL1,所以linux的發行版本部分命令還不能使用,比如systemctl命令。此處啟動docker可以使用:sudo systemctl start docker
# Step 8:拉取hello-world鏡像,驗證docker是否正常
# docker run hello-world
# 輸出:
# Hello from Docker!
# This message shows that your installation appears to be working correctly.
# ......
參考:
https://yeasy.gitbooks.io/docker_practice/install/ubuntu.html
https://developer.aliyun.com/mirror/docker-ce?spm=a2c6h.13651102.0.0.3e221b11N33sKY
