[LOGO]
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
gitlab-ce | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): base/7/x86_64/group_gz | 165 kB 00:00:05
(2/5): extras/7/x86_64/primary_db | 153 kB 00:00:05
(3/5): updates/7/x86_64/primary_db | 5.8 MB 00:00:05
(4/5): base/7/x86_64/primary_db | 6.0 MB 00:00:06
(5/5): gitlab-ce/primary_db | 3.3 MB 00:00:06
Determining fastest mirrors
* base: mirror.jdcloud.com
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.6.3-1.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-1.el7 will be an update
---> Package lvm2.x86_64 7:2.02.166-1.el7 will be updated
---> Package lvm2.x86_64 7:2.02.185-2.el7_7.2 will be an update
--> Processing Dependency: lvm2-libs = 7:2.02.185-2.el7_7.2 for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_141)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_138)(64bit) for package: 7:lvm2-2.02.185-2.el7_7.2.x86_64
---> Package yum-utils.noarch 0:1.1.31-40.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-52.el7 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.135-1.el7 will be updated
--> Processing Dependency: device-mapper-libs = 7:1.02.135-1.el7 for package: 7:device-mapper-1.02.135-1.el7.x86_64
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package lvm2-libs.x86_64 7:2.02.166-1.el7 will be updated
---> Package lvm2-libs.x86_64 7:2.02.185-2.el7_7.2 will be an update
--> Processing Dependency: device-mapper-event = 7:1.02.158-2.el7_7.2 for package: 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.135-1.el7 will be updated
---> Package device-mapper.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package device-mapper-event.x86_64 7:1.02.135-1.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.158-2.el7_7.2 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.158-2.el7_7.2 for package: 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 7:1.02.135-1.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================================================================================================================
Updating:
device-mapper-persistent-data x86_64 0.8.5-1.el7 base 423 k
lvm2 x86_64 7:2.02.185-2.el7_7.2 updates 1.3 M
yum-utils noarch 1.1.31-52.el7 base 121 k
Updating for dependencies:
device-mapper x86_64 7:1.02.158-2.el7_7.2 updates 294 k
device-mapper-event x86_64 7:1.02.158-2.el7_7.2 updates 190 k
device-mapper-event-libs x86_64 7:1.02.158-2.el7_7.2 updates 189 k
device-mapper-libs x86_64 7:1.02.158-2.el7_7.2 updates 322 k
lvm2-libs x86_64 7:2.02.185-2.el7_7.2 updates 1.1 M
Transaction Summary
=======================================================================================================================================================================================================================================================================
Upgrade 3 Packages (+5 Dependent packages)
Total download size: 3.9 M
Downloading packages:
No Presto metadata available for base
No Presto metadata available for updates
(1/8): device-mapper-1.02.158-2.el7_7.2.x86_64.rpm | 294 kB 00:00:05
(2/8): device-mapper-event-1.02.158-2.el7_7.2.x86_64.rpm | 190 kB 00:00:05
(3/8): device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64.rpm | 189 kB 00:00:00
(4/8): device-mapper-libs-1.02.158-2.el7_7.2.x86_64.rpm | 322 kB 00:00:00
(5/8): lvm2-2.02.185-2.el7_7.2.x86_64.rpm | 1.3 MB 00:00:00
(6/8): lvm2-libs-2.02.185-2.el7_7.2.x86_64.rpm | 1.1 MB 00:00:00
(7/8): device-mapper-persistent-data-0.8.5-1.el7.x86_64.rpm | 423 kB 00:00:05
(8/8): yum-utils-1.1.31-52.el7.noarch.rpm | 121 kB 00:00:05
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 344 kB/s | 3.9 MB 00:00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64 1/16
Updating : 7:device-mapper-1.02.158-2.el7_7.2.x86_64 2/16
Updating : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64 3/16
Updating : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64 4/16
Updating : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64 5/16
Updating : device-mapper-persistent-data-0.8.5-1.el7.x86_64 6/16
Updating : 7:lvm2-2.02.185-2.el7_7.2.x86_64 7/16
Updating : yum-utils-1.1.31-52.el7.noarch 8/16
Cleanup : yum-utils-1.1.31-40.el7.noarch 9/16
Cleanup : 7:lvm2-2.02.166-1.el7.x86_64 10/16
Cleanup : 7:lvm2-libs-2.02.166-1.el7.x86_64 11/16
Cleanup : 7:device-mapper-event-1.02.135-1.el7.x86_64 12/16
Cleanup : 7:device-mapper-event-libs-1.02.135-1.el7.x86_64 13/16
Cleanup : 7:device-mapper-libs-1.02.135-1.el7.x86_64 14/16
Cleanup : 7:device-mapper-1.02.135-1.el7.x86_64 15/16
Cleanup : device-mapper-persistent-data-0.6.3-1.el7.x86_64 16/16
Verifying : 7:device-mapper-1.02.158-2.el7_7.2.x86_64 1/16
Verifying : device-mapper-persistent-data-0.8.5-1.el7.x86_64 2/16
Verifying : yum-utils-1.1.31-52.el7.noarch 3/16
Verifying : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64 4/16
Verifying : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64 5/16
Verifying : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64 6/16
Verifying : 7:lvm2-2.02.185-2.el7_7.2.x86_64 7/16
Verifying : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64 8/16
Verifying : device-mapper-persistent-data-0.6.3-1.el7.x86_64 9/16
Verifying : 7:device-mapper-event-libs-1.02.135-1.el7.x86_64 10/16
Verifying : 7:device-mapper-1.02.135-1.el7.x86_64 11/16
Verifying : 7:lvm2-2.02.166-1.el7.x86_64 12/16
Verifying : yum-utils-1.1.31-40.el7.noarch 13/16
Verifying : 7:device-mapper-libs-1.02.135-1.el7.x86_64 14/16
Verifying : 7:device-mapper-event-1.02.135-1.el7.x86_64 15/16
Verifying : 7:lvm2-libs-2.02.166-1.el7.x86_64 16/16
Updated:
device-mapper-persistent-data.x86_64 0:0.8.5-1.el7 lvm2.x86_64 7:2.02.185-2.el7_7.2 yum-utils.noarch 0:1.1.31-52.el7
Dependency Updated:
device-mapper.x86_64 7:1.02.158-2.el7_7.2 device-mapper-event.x86_64 7:1.02.158-2.el7_7.2 device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2 device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2 lvm2-libs.x86_64 7:2.02.185-2.el7_7.2
Complete!
[root@localhost ~]#
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: 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
yum install docker-ce
[root@localhost ~]# yum install docker-ce
Loaded plugins: fastestmirror, langpacks
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:05
(2/2): docker-ce-stable/x86_64/primary_db | 37 kB 00:00:05
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:19.03.5-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-19.03.5-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-19.03.5-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-19.03.5-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
---> Package containerd.io.x86_64 0:1.2.10-3.2.el7 will be installed
---> Package docker-ce-cli.x86_64 1:19.03.5-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================================================================================================================
Installing:
docker-ce x86_64 3:19.03.5-3.el7 docker-ce-stable 24 M
Installing for dependencies:
container-selinux noarch 2:2.107-3.el7 extras 39 k
containerd.io x86_64 1.2.10-3.2.el7 docker-ce-stable 23 M
docker-ce-cli x86_64 1:19.03.5-3.el7 docker-ce-stable 39 M
Transaction Summary
=======================================================================================================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 87 M
Installed size: 362 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): container-selinux-2.107-3.el7.noarch.rpm | 39 kB 00:00:05
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.5-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY= ] 12 MB/s | 23 MB 00:00:05 ETA
Public key for docker-ce-19.03.5-3.el7.x86_64.rpm is not installed
(2/4): docker-ce-19.03.5-3.el7.x86_64.rpm | 24 MB 00:00:06
(3/4): containerd.io-1.2.10-3.2.el7.x86_64.rpm | 23 MB 00:00:07
(4/4): docker-ce-cli-19.03.5-3.el7.x86_64.rpm | 39 MB 00:00:01
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s | 87 MB 00:00:08
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) "
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.107-3.el7.noarch 1/4
setsebool: SELinux is disabled.
Installing : containerd.io-1.2.10-3.2.el7.x86_64 2/4
Installing : 1:docker-ce-cli-19.03.5-3.el7.x86_64 3/4
Installing : 3:docker-ce-19.03.5-3.el7.x86_64 4/4
Verifying : containerd.io-1.2.10-3.2.el7.x86_64 1/4
Verifying : 1:docker-ce-cli-19.03.5-3.el7.x86_64 2/4
Verifying : 2:container-selinux-2.107-3.el7.noarch 3/4
Verifying : 3:docker-ce-19.03.5-3.el7.x86_64 4/4
Installed:
docker-ce.x86_64 3:19.03.5-3.el7
Dependency Installed:
container-selinux.noarch 2:2.107-3.el7 containerd.io.x86_64 0:1.2.10-3.2.el7 docker-ce-cli.x86_64 1:19.03.5-3.el7
Complete!
[root@localhost ~]#
systemctl start docker
systemctl enable docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]#
[root@localhost ~]# 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
[root@localhost ~]#
查看默认主目录:
[root@VM-0-2-centos srv]# sudo docker info | grep "Docker Root Dir"
Docker Root Dir: /var/lib/docker
修改docker的默认配置文件(/etc/docker):daemon.json(如果没有则新建一个即可)
添加"graph": "/srv/docker"的键值对,值为你磁盘的目录(自己新建一下即可),一般为数据盘/data下。
[root@VM-0-2-centos docker]# vim daemon.json
[root@VM-0-2-centos docker]# cat daemon.json
{
"graph": "/data/docker"
}
[root@VM-0-2-centos docker]# sudo docker info | grep "Docker Root Dir"
Docker Root Dir: /data/docker
注意:如果graph不好使,启动docker启动不起来,则尝试用data-home参数设置:
{
"data-root": "/data/docker"
}
这样可以避免默认的磁盘太小,导致用尽的情况,用尽的处理方式直通车:
记一次docker磁盘用尽的灾难 https://blog.csdn.net/wdy_2099/article/details/103967788