Centos7 上安装docker

Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE。

社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施、容器、插件等。

社区版按照stable和edge两种方式发布,每个季度更新stable版本,如17.06,17.09;每个月份更新edge版本,如17.09,17.10。

一、安装docker

参考:https://docs.docker.com/install/linux/docker-ce/centos/#uninstall-old-versions 【安装网址】

1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

通过 uname -r 命令查看你当前的内核版本

$ uname -r

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

$ yum update

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

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

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

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

5、设置yum源

外国镜像
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
阿里镜像
[root@node3 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

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

$ yum list docker-ce --showduplicates | sort -r
[root@node3 ~]# yum list docker-ce --showduplicates | sort -r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:19.03.4-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 17.03.0.ce-1.el7.centos docker-ce-stable
* base: centos.ustc.edu.cn
Available Packages

7、安装docker

7.1 由于repo中默认只开启stable仓库,故这里安装的是最新稳定版17.12.0

$ yum install docker-ce

7.2安装指定版本

$ yum install <FQPN>  # 例如:yum install docker-ce-17.12.0.ce

暴力卸载

yum remove docker docker-common docker-selinux docker-engine -y
/etc/systemd -name '*docker*' -exec rm -f {} ;
find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /lib/systemd -name '*docker*' -exec rm -f {} \;

8、启动并加入开机启动

$ systemctl start docker
$ systemctl enable docker

9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

$ docker version
[root@node3 ~]# docker version
Client: Docker Engine - Community
Version: 19.03.4
API version: 1.40
Go version: go1.12.10
Git commit: 9013bf583a
Built: Fri Oct 18 15:52:22 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.4
API version: 1.40 (minimum version 1.12)
Go version: go1.12.10
Git commit: 9013bf583a
Built: Fri Oct 18 15:50:54 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683

二、问题

1、因为之前已经安装过旧版本的docker,在安装的时候报错如下:

Transaction check error:
file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

2、卸载旧版本的包

$ yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

3、再次安装docker

$ yum install docker-ce

4、拉取镜像异常

[root@node3 ~]# docker run hello-world
Unable to find image 'hell0-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout.

==》若仓库没有先拉取去hello-warld镜像,也有可能是网络原因,建议使用国内镜像

5、镜像已经存在

[root@node3 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Already exists
Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest

最新文章

  1. 第八章 交互技术,8.4 Weex 双11会场大规模应用的秒开实战和稳定性保障(作者:鬼道)
  2. commons-io ProxyInputStream,ProxyOutputStream,ProxyReader,ProxyWriter
  3. SQL server2008-对象资源管理器-数据库
  4. sqlite_
  5. 用DOS批处理实现FTP自动上传、下载、清理文件
  6. jQuery基础之(六)jQuery浏览器的兼容性(以CSS3特写兼容举例)
  7. Windows与Linux/Mac系统时间不一致的解决方法
  8. PHP强制清除缓存
  9. c++ 重定位输出到DOS
  10. 界面编程模仿篇(QQ登录界面逼真篇)
  11. VI01增强问题
  12. mybatis返回int类型报null
  13. DRUID连接池配置详情
  14. Linux记录-open-falcon开源监控系统部署
  15. 学习MeteoInfo二次开发教程(七)
  16. maven 多个jar包版本依赖问题
  17. Linux基础命令---修改组信息grpmod
  18. skipper prometheus 监控
  19. work单进程群发通知 后面会增加Channel组件的分组推送以及集群推送篇章
  20. ubuntu下交叉编译mono

热门文章

  1. sql 查询某一列最大的数据
  2. 缓存融合(Cache Fusion)介绍
  3. harbor设置开机自启
  4. 【HANA系列】SAP HANA Studio代码提示设置方法
  5. 服务器上安装并使用tensorboard
  6. sklearn.preprocessing.StandardScaler数据标准化
  7. 《React+Redux前端开发实战》笔记3:基于Webpack构建的Hello World案例(下)
  8. windeployqt.exe 发布windows下qt产生的exe程序
  9. BadUsb简单用法示例
  10. mavn Nexus Repository Manager漏洞