Linux-CentOS | Docker安装 | 终端连接Li
2019-11-25 本文已影响0人
夏浩文
-
获取权限
1、root
权限用户登录
2、sudo
命令获取权限
-
内核版本检测
Docker
要求CentOS系统的内核版本高于3.10
uname -r
检测版本大于3.10即可正常使用
[root@VM_0_12_centos ~]# uname -r
3.10.0-957.21.3.el7.x86_64
-
更新yum
yum update
yum安装需依赖yum-utils
、device-mapper-persistent-data
、lvm2
yum install -y yum-utils device-mapper-persistent-data lvm2
若更新过程中,python依赖包更新失败
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在更新:
python-urllib3 noarch 1.10.2-7.el7 os 103 k
事务概要
================================================================================
升级 1 软件包
/// 更新失败⤵️
Running transaction
正在更新 : python-urllib3-1.10.2-7.el7.noarch 1/2
Error unpacking rpm package python-urllib3-1.10.2-7.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
验证中 : python-urllib3-1.10.2-7.el7.noarch 1/2
python-urllib3-1.10.2-5.el7.noarch was supposed to be removed but is not!
验证中 : python-urllib3-1.10.2-5.el7.noarch 2/2
失败:
python-urllib3.noarch 0:1.10.2-5.el7 python-urllib3.noarch 0:1.10.2-7.el7
完毕!
可这样操作
pip install --upgrade urllib3
-
配置Docker CE仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
可见docker-ce.repo
已添加
[root@VM_0_12_centos yum.repos.d]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@VM_0_12_centos yum.repos.d]# ls
CentOS-Base.repo CentOS-Epel.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-Media.repo docker-ce.repo
刷新缓存
yum makecache fast
⬇️
[root@VM_0_12_centos yum.repos.d]# yum makecache fast
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00
epel | 5.3 kB 00:00
extras | 2.9 kB 00:00
os | 3.6 kB 00:00
updates | 2.9 kB 00:00
元数据缓存已建立
-
安装Docker
查看docker
版本
yum list docker-ce --showduplicates //| sort -r
可选择版本安装
yum install docker-ce-3:19.03.5-3.el7.ce
或不选择
yum -y install docker-ce
完成后查看版本
docker version
可见c-v版本
[root@VM_0_12_centos ~]# docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:24:18 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
-
启动Docker
启动
systemctl start docker
设置开机启动
systemctl enable docker
查看启动状态
systemctl status docker
若为active (running)
,则启动成功
[root@VM_0_12_centos ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-11-25 11:03:53 CST; 1h 26min ago
Docs: https://docs.docker.com
Main PID: 14312 (dockerd)
CGroup: /system.slice/docker.service
└─14312 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/con...
11月 25 11:03:52 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:52.8...c
11月 25 11:03:52 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:52.8...c
11月 25 11:03:52 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:52.8..."
11月 25 11:03:52 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:52.9..."
11月 25 11:03:53 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:53.3..."
11月 25 11:03:53 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:53.5..."
11月 25 11:03:53 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:53.6...5
11月 25 11:03:53 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:53.6..."
11月 25 11:03:53 VM_0_12_centos dockerd[14312]: time="2019-11-25T11:03:53.6..."
11月 25 11:03:53 VM_0_12_centos systemd[1]: Started Docker Application Cont....
Hint: Some lines were ellipsized, use -l to show in full.
附
- 终端直接连接Linux
ssh [用户名]@[ip地址]