本文共 3650 字,大约阅读时间需要 12 分钟。
依赖配置:
1.查看是否有旧的安装包,如果有,需要卸载
yum remove docker docker-common docker-selinux docker-engine
2.检查内核版本(Docker 要求 CentOS 系统的内核版本高于 3.10)
[root@eric112 ~]# uname -r4.17.8-1.el7.elrepo.x86_64
如果你的版本不满足需求,需要升级内核
方法一:通过yum安装
1.安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2
2.添加docker的yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3.查看仓库中可用的docker版本,然后选择指定的版本安装
[root@eric112 ~]# yum list docker-ce --showduplicates | sort -rRepository epel is listed more than once in the configurationRepository epel-debuginfo is listed more than once in the configurationRepository epel-source is listed more than once in the configuration已加载插件:fastestmirror可安装的软件包 * updates: mirrors.aliyun.comLoading mirror speeds from cached hostfile * extras: mirrors.aliyun.com * elrepo: mirrors.tuna.tsinghua.edu.cndocker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable * base: mirrors.aliyun.com
4.安装docker
yum install#FULLY-QUALIFIED-PACKAGE-NAME为docker-ce-详细版本号,如docke-ce-17.06.2.ce-1.el7.centos或者yum install docker-ce #安装最新的稳定版
5.验证docker是否安装成功(有client和service两部分表示docker安装启动都成功了)
[root@eric112 ~]# docker versionClient: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:08:18 2018 OS/Arch: linux/amd64 Experimental: false
6.启动docker
systemctl start docker #启动dockersystemctl enable docker #设置docker为开机自启
7.查看docker是否启动成功
[root@eric112 ~]# systemctl status docker● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since 五 2018-08-03 23:06:03 CST; 5s ago Docs: https://docs.docker.com Main PID: 1450 (dockerd) Tasks: 28 Memory: 50.2M CGroup: /system.slice/docker.service ├─1450 /usr/bin/dockerd └─1458 docker-containerd --config /var/run/docker/containerd/containerd.toml
方法二:通过脚本安装
curl -fsSL https://get.docker.com/ | sh #最新正式版或者wget -qO- https://get.docker.com/ | sh #最新正式版或者curl -fsSL https://test.docker.com/ | sh #预发布版本,不建议在生成中使用
至此,docker安装启动成功。
卸载docker
1.查看已安装的docker
[root@eric112 ~]# yum list installed | grep dockerRepository epel is listed more than once in the configurationRepository epel-debuginfo is listed more than once in the configurationRepository epel-source is listed more than once in the configurationdocker-ce.x86_64 18.06.0.ce-3.el7 @docker-ce-stable
2.使用yum卸载
yum remove -y docker-ce.x86_64 #docker-ce.x86_64为已安装的docker,以实际安装的版本为准
转载地址:http://ddgsi.baihongyu.com/