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

猜你喜欢

转载自blog.csdn.net/guanheng68/article/details/81710155
今日推荐