CentOS 7下:使用yum来安装docker ce 17.09以上版本

卸载老版本

老版本的Docker在yum中名称为docker或docker-engine,如果之前安装过,必须先卸载,包括相关的依赖。

yum remove docker \
    docker-common \
    docker-selinux \
    docker-engine

如果yum命令的执行结果说没有packages已经安装过,那也没事。
原先使用docker/docker-engine安装的内容都在/var/lib/docker/下,包括images, containers, volumes, and networks,都会被保留的。
新的Docker CE在yum中被称为docker-ce。(因为分化为docker-ce和docker-ee,后者为企业版)

Install Docker CE

  • 首次安装Docker CE,需要set up the Docker repository。然后就可以使用yum来install and update了.
  • 搭建Docker CE的REPOSITORY
# Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
# Use the following command to set up the stable repository. You always need the stablerepository, even if you want to install builds from the edge or test repositories as well.
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
  • 安装 DOCKER CE
# Install the latest version of Docker CE, or go to the next step to install a specific version.
yum install docker-ce
  • 在正式环境,必须使用统一的稳定版本,而不是总使用最新(这样各host上的版本可能不一致)。下面这个例子是使用sort -r 命令来排序docker-ce的版本,从高到低。
yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.0.ce-1.el7.centos            @docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable 

yum install docker-ce-17.09.0.ce
  • Start Docker.
systemctl start docker
  • 使用docker version命令来确认一下
$docker version
Client:
 Version: 17.09.0-ce
 API version: 1.32
 Go version: go1.8.3
 Git commit: afdb6d4
 Built: Tue Sep 26 22:41:23 2017
 OS/Arch: linux/amd64

Server:
 Version: 17.09.0-ce
 API version: 1.32 (minimum version 1.12)
 Go version: go1.8.3
 Git commit: afdb6d4
 Built: Tue Sep 26 22:42:49 2017
 OS/Arch: linux/amd64
 Experimental: false
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值