docker的安装与卸载

天大地大妈咪最大 提交于 2020-02-26 16:28:46

安装docker

安装要求:
  1. 仅适用64位linux安装(uname --m)
  2. 需要内核版本3.10或更高版本(uname -r)
安装步骤:

使用 root 权限登录 Centos。确保 yum 包更新到最新。

$ sudo yum update

卸载旧版本(如果安装过旧版本的话)

$ sudo yum remove docker  docker-common docker-selinux docker-engine

安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

设置yum源


$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

可以在/etc/yum.d.repos/中看到新增的docker-ce.repo

[root@localhost yum.repos.d]# ls
CentOS-Base.repo      CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  docker-ce.repo
CentOS-Base.repo.bak  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo    epel-7.repo

可以查看所有仓库中所有docker版本,并选择特定版本安装

yum list docker-ce --showduplicates | sort -r
[root@localhost yum.repos.d]# yum list docker-ce --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.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.3.ce-1.el7                    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
Available Packages

安装docker,命令:yum install docker-ce-版本号,如:

[root@localhost yum.repos.d]# yum install docker-ce-3:19.03.6

尝试过安装:3:19.03.6-3.el7,但没有成功:

[root@localhost yum.repos.d]# yum install docker-ce-3:19.03.6
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package docker-ce-3:19.03.6 available.
Error: Nothing to do
[root@localhost yum.repos.d]# yum install docker-ce-3:19.03.6-3
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package docker-ce-3:19.03.6-3 available.
Error: Nothing to do
[root@localhost yum.repos.d]# yum install docker-ce-3:19.03.6-3.el7
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package docker-ce-3:19.03.6-3.el7 available.
Error: Nothing to do

安装好后启动docker:

[root@localhost yum.repos.d]# systemctl start docker.service

验证安装是否成功:

[root@localhost yum.repos.d]# docker version
Client:
 Version:           18.06.3-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        d7080c1
 Built:             Wed Feb 20 02:26:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.3-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       d7080c1
  Built:            Wed Feb 20 02:28:17 2019
  OS/Arch:          linux/amd64
  Experimental:     false

参考:https://www.cnblogs.com/shuaiandjun/p/9375023.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!