經過Repository方式,在Ubuntu16.04中安裝Docker社區版。linux
老版本的Docker在倉庫中的名稱是docker或者docker-engine,若是已安裝,首先卸載掉。docker
$ sudo apt-get remove docker docker-engine docker.io
2.1 安裝軟件以使apt使用httpsjson
$ sudo apt-get update && \ sudo apt-get install \ apt-transport-https \ ca-certificates \ software-properties-common \ curl
2.2 添加官方GPG keyubuntu
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
驗證key的指紋是9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88curl
$ sudo apt-key fingerprint 0EBFCD88 pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid Docker Release (CE deb) <docker@docker.com> sub 4096R/F273FCD8 2017-02-22
2.3 添加倉庫ui
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
或者url
$ echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list
2.4 安裝rest
$ sudo apt-get update && \ sudo apt-get install docker-ce
2.5 若是沒有權限code
$ sudo usermod -aG docker ${USER}
a. 查詢可用版本ip
$ apt-cache madison docker-ce docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
b. 安裝指定版本,docker-ce=<version>,version使用第二列的字符串
$ sudo apt-get install docker-ce=18.03.0~ce-0~ubuntu
加速docker pull的拉取速度,新建/etc/docker/daemon.json文件,添加:
{ "registry-mirrors": ["https://registry.docker-cn.com"] }
保存後sudo systemctl restart docker重啓docker。
Ok
參考:
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository https://docs.docker.com/registry/recipes/mirror/#use-case-the-china-registry-mirror