docker的安装
以前叫做 Docker engine安装现在叫做docker-ce的安装
`root下执行,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`
上面有时候会由于网络问题下载超时,可以使用下面的国内镜像来安装
`curl -sSL https:``//get.daocloud.io/docker | sh`
或者借助阿里源
`# 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 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]`
说明一点
上面的脚本安装方法固然很快方便,但是官方不建议我们这么做,
参考:这里
`Using these scripts is not recommended ``for` `production environments, and you should understand the potential risks before you use them`
docker的升级
对于上面使用脚本来安装的升级很简单,参见官方文档
If you installed Docker using the convenience script, you should upgrade Docker using your package manager directly.
所以升级的话我们只需要使用apt-get来升级
`sudo apt-get update`
`sudo apt-cache madison docker-ce #搜索可以升级的稳定版本`
`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`
`升级`
`sudo apt-get -y install docker-ce=[VERSION]`
docker的卸载
`sudo apt-get remove docker docker-engine`
卸载Docker后,/var/lib/docker/目录下会保留原Docker的镜像,网络,存储卷等文件. 如果需要全新安装Docker,需要删除/var/lib/docker/目录
`rm -rf /var/lib/docker/`
直接拉取会报错
image.png
- 可以先ping 一下路径 ping reg.d.huntor.cn
- 首先在 vi /etc/hosts 中添加内网路径映射
192.168.1.101 reg.d.huntor.cn
3.在/etc/docker 中添加daemon.json 内容为{"registry-mirrors": ["http://dc945b6d.m.daocloud.io "],"insecure-registries":["reg.d.huntor.cn"]}
起到加速的作用
4./etc/init.d/docker restart 重启docker
网友评论