docker的安裝
以前叫做 Docker engine安裝現(xiàn)在叫做docker-ce的安裝
`root下執(zhí)行站故,sudo su - root`
`apt-get update -y`
`which wget > /dev/``null` `|| apt-get -qq install -y wget`
`wget -qO- https:``//get.docker.com/gpg | apt-key add -`
`wget -qO- https:``//get.docker.com/ | sh`
`docker version`
上面有時(shí)候會(huì)由于網(wǎng)絡(luò)問題下載超時(shí),可以使用下面的國(guó)內(nèi)鏡像來安裝
`curl -sSL https:``//get.daocloud.io/docker | sh`
或者借助阿里源
`# step ``1``: 安裝必要的一些系統(tǒng)工具`
`sudo apt-get update`
`sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common`
`# step ``2``: 安裝GPG證書`
`curl -fsSL http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -`
`# Step ``3``: 寫入軟件源信息`
`sudo add-apt-repository ``"deb [arch=amd64] [http://mirrors.aliyun.com/docker-ce/linux/ubuntu](http://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-CE:`
`# Step ``1``: 查找Docker-CE的版本:`
`# apt-cache madison docker-ce`
`# docker-ce | ``17.03``.``1``~ce-``0``~ubuntu-xenial | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages`
`# docker-ce | ``17.03``.``0``~ce-``0``~ubuntu-xenial | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages`
`# Step ``2``: 安裝指定版本的Docker-CE: (VERSION 例如上面的 ``17.03``.``1``~ce-``0``~ubuntu-xenial)`
`# sudo apt-get -y install docker-ce=[VERSION]`
說明一點(diǎn)
上面的腳本安裝方法固然很快方便,但是官方不建議我們這么做,
參考:這里
`Using these scripts is not recommended ``for` `production environments, and you should understand the potential risks before you use them`
docker的升級(jí)
對(duì)于上面使用腳本來安裝的升級(jí)很簡(jiǎn)單茉盏,參見官方文檔
If you installed Docker using the convenience script, you should upgrade Docker using your package manager directly.
所以升級(jí)的話我們只需要使用apt-get來升級(jí)
`sudo apt-get update`
`sudo apt-cache madison docker-ce #搜索可以升級(jí)的穩(wěn)定版本`
`sudo apt-cache madison docker-ce`
`docker-ce | ``17.06``.``2``~ce-``0``~ubuntu | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`docker-ce | ``17.06``.``1``~ce-``0``~ubuntu | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`docker-ce | ``17.06``.``0``~ce-``0``~ubuntu | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`docker-ce | ``17.03``.``2``~ce-``0``~ubuntu-trusty | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`docker-ce | ``17.03``.``1``~ce-``0``~ubuntu-trusty | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`docker-ce | ``17.03``.``0``~ce-``0``~ubuntu-trusty | http:``//mirrors.aliyun.com/docker-ce/linux/ubuntu/ trusty/stable amd64 Packages`
`升級(jí)`
`sudo apt-get -y install docker-ce=[VERSION]`
docker的卸載
`sudo apt-get remove docker docker-engine`
卸載Docker后,/var/lib/docker/目錄下會(huì)保留原Docker的鏡像,網(wǎng)絡(luò),存儲(chǔ)卷等文件. 如果需要全新安裝Docker,需要?jiǎng)h除/var/lib/docker/目錄
`rm -rf /var/lib/docker/`
直接拉取會(huì)報(bào)錯(cuò)
- 可以先ping 一下路徑 ping reg.d.huntor.cn
- 首先在 vi /etc/hosts 中添加內(nèi)網(wǎng)路徑映射
192.168.1.101 reg.d.huntor.cn
3.在/etc/docker 中添加daemon.json 內(nèi)容為{"registry-mirrors": ["http://dc945b6d.m.daocloud.io "],"insecure-registries":["reg.d.huntor.cn"]}
起到加速的作用
4./etc/init.d/docker restart 重啟docker