赞
踩
搭建docker有两种方法
方法1:通过国内源安装docker
方法2:通过rpm安装docker
首先需要先安装docker的依赖包yum-utils,device-mapper-persistent-data,lvm2
[root@localhost ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 will be installed
---> Package lvm2.x86_64 7:2.02.177-4.el7 will be installed
---> Package yum-utils.noarch 0:1.1.31-45.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================================
Installing:
device-mapper-persistent-data x86_64 0.7.3-3.el7 centos7 405 k
lvm2 x86_64 7:2.02.177-4.el7 centos7 1.3 M
yum-utils noarch 1.1.31-45.el7 centos7 119 k
Transaction Summary
======================================================================================================================================================================================================
Install 3 Packages
Total download size: 1.8 M
Installed size: 4.5 M
Downloading packages:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 7.0 MB/s | 1.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : device-mapper-persistent-data-0.7.3-3.el7.x86_64 1/3
Installing : 7:lvm2-2.02.177-4.el7.x86_64 2/3
Installing : yum-utils-1.1.31-45.el7.noarch 3/3
Verifying : yum-utils-1.1.31-45.el7.noarch 1/3
Verifying : device-mapper-persistent-data-0.7.3-3.el7.x86_64 2/3
Verifying : 7:lvm2-2.02.177-4.el7.x86_64 3/3
Installed:
device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 lvm2.x86_64 7:2.02.177-4.el7 yum-utils.noarch 0:1.1.31-45.el7
Complete!
这里我们使用的是国内源
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
此时我们看见,安装docker-ce时出现报错
[root@localhost ~]# yum -y install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00
(1/2): docker-ce-stable/7/x86_64/primary_db | 117 kB 00:00:01
(2/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:07
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:24.0.6-1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: containerd.io >= 1.6.4 for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.22-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.22-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:24.0.6-1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-24.0.6-1.el7.x86_64
---> Package docker-ce-cli.x86_64 1:24.0.6-1.el7 will be installed
--> Processing Dependency: docker-buildx-plugin for package: 1:docker-ce-cli-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-compose-plugin for package: 1:docker-ce-cli-24.0.6-1.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:24.0.6-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
---> Package libcgroup.x86_64 0:0.41-15.el7 will be installed
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.22-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.22-3.1.el7.x86_64
---> Package docker-buildx-plugin.x86_64 0:0.11.2-1.el7 will be installed
---> Package docker-ce.x86_64 3:24.0.6-1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-24.0.6-1.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:24.0.6-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
---> Package docker-compose-plugin.x86_64 0:2.21.0-1.el7 will be installed
--> Finished Dependency Resolution
Error: Package: containerd.io-1.6.22-3.1.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
Error: Package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64 (docker-ce-stable)
Requires: fuse-overlayfs >= 0.7
Error: Package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64 (docker-ce-stable)
Requires: slirp4netns >= 0.4
Error: Package: 3:docker-ce-24.0.6-1.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
这里我们下载的是阿里源(需要通过网络源安装一些包)
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2023-09-09 12:26:35-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 106.116.171.248, 182.40.51.241, 140.249.90.201, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|106.116.171.248|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[============================================================================================================================================================>] 2,523 --.-K/s in 0.002s
2023-09-09 12:26:36 (1.28 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@localhost ~]# yum -y install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/6): docker-ce-stable/7/x86_64/primary_db | 117 kB 00:00:00
(2/6): extras/7/x86_64/primary_db | 250 kB 00:00:00
(3/6): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(4/6): base/7/x86_64/group_gz | 153 kB 00:00:01
(5/6): updates/7/x86_64/primary_db | 22 MB 00:00:11
base/7/x86_64/primary_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(6/6): base/7/x86_64/primary_db | 6.1 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
Transaction Summary
======================================================================================================================================================================================================
Install 1 Package
Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY ] 0.0 B/s | 0 B --:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1
Installed:
epel-release.noarch 0:7-11
Complete!
yum makecache 是 将服务器上的软件包信息 现在本地缓存,以提高 搜索 安装软件的速度
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 4.8 kB 00:00:00
* base: mirrors.aliyun.com
* epel: ftp.riken.jp
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
centos7 | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/16): centos7/other_db | 1.3 MB 00:00:00
(2/16): centos7/filelists_db | 3.1 MB 00:00:00
(3/16): docker-ce-stable/7/x86_64/filelists_db | 47 kB 00:00:00
(4/16): docker-ce-stable/7/x86_64/other_db | 134 kB 00:00:00
(5/16): base/7/x86_64/other_db | 2.6 MB 00:00:01
(6/16): base/7/x86_64/filelists_db | 7.2 MB 00:00:02
(7/16): epel/x86_64/prestodelta | 1.1 kB 00:00:01
(8/16): epel/x86_64/group_gz | 99 kB 00:00:04
(9/16): extras/7/x86_64/filelists_db | 303 kB 00:00:00
(10/16): extras/7/x86_64/other_db | 150 kB 00:00:00
(11/16): updates/7/x86_64/filelists_db | 12 MB 00:00:02
(12/16): updates/7/x86_64/other_db | 1.4 MB 00:00:00
(13/16): epel/x86_64/updateinfo | 1.0 MB 00:00:20
(14/16): epel/x86_64/primary_db | 7.0 MB 00:01:53
(15/16): epel/x86_64/other_db | 3.4 MB 00:05:01
(16/16): epel/x86_64/filelists_db | 12 MB 00:05:50
Metadata Cache Created
[root@localhost ~]# yum -y install container-selinux
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: ftp.riken.jp
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-34.el7 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package selinux-policy.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be an update
--> Processing Dependency: libsemanage >= 2.5-13 for package: selinux-policy-3.13.1-268.el7_9.2.noarch
---> Package selinux-policy-targeted.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be an update
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.5-4.el7 for package: audit-libs-python-2.8.5-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage.x86_64 0:2.5-11.el7 will be updated
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
--> Processing Dependency: libsepol >= 2.5-10 for package: libsemanage-2.5-14.el7.x86_64
--> Processing Dependency: libselinux >= 2.5-14 for package: libsemanage-2.5-14.el7.x86_64
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-22.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-34.el7.x86_64
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.8.1-3.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.1-3.el7 for package: audit-2.8.1-3.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
---> Package libselinux.x86_64 0:2.5-12.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-python-2.5-12.el7.x86_64
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be an update
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.1-3.el7 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================================
Installing:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 base 76 k
checkpolicy x86_64 2.5-8.el7 base 295 k
libcgroup x86_64 0.41-21.el7 base 66 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
Updating for dependencies:
audit x86_64 2.8.5-4.el7 base 256 k
audit-libs x86_64 2.8.5-4.el7 base 102 k
libselinux x86_64 2.5-15.el7 base 162 k
libselinux-python x86_64 2.5-15.el7 base 236 k
libselinux-utils x86_64 2.5-15.el7 base 151 k
libsemanage x86_64 2.5-14.el7 base 151 k
libsepol x86_64 2.5-10.el7 base 297 k
policycoreutils x86_64 2.5-34.el7 base 917 k
selinux-policy noarch 3.13.1-268.el7_9.2 updates 498 k
selinux-policy-targeted noarch 3.13.1-268.el7_9.2 updates 7.0 M
Transaction Summary
======================================================================================================================================================================================================
Install 1 Package (+ 7 Dependent packages)
Upgrade ( 10 Dependent packages)
Total download size: 11 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/18): audit-libs-2.8.5-4.el7.x86_64.rpm | 102 kB 00:00:00
(2/18): audit-2.8.5-4.el7.x86_64.rpm | 256 kB 00:00:00
(3/18): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(4/18): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(5/18): libselinux-2.5-15.el7.x86_64.rpm | 162 kB 00:00:00
(6/18): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(7/18): libselinux-python-2.5-15.el7.x86_64.rpm | 236 kB 00:00:00
(8/18): libselinux-utils-2.5-15.el7.x86_64.rpm | 151 kB 00:00:00
(9/18): libsemanage-2.5-14.el7.x86_64.rpm | 151 kB 00:00:00
(10/18): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(11/18): libsepol-2.5-10.el7.x86_64.rpm | 297 kB 00:00:00
(12/18): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(13/18): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(14/18): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00
(15/18): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(16/18): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(17/18): selinux-policy-3.13.1-268.el7_9.2.noarch.rpm | 498 kB 00:00:00
(18/18): selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm | 7.0 MB 00:00:02
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.7 MB/s | 11 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libsepol-2.5-10.el7.x86_64 1/28
Updating : libselinux-2.5-15.el7.x86_64 2/28
Updating : audit-libs-2.8.5-4.el7.x86_64 3/28
Updating : libsemanage-2.5-14.el7.x86_64 4/28
Updating : libselinux-utils-2.5-15.el7.x86_64 5/28
Updating : policycoreutils-2.5-34.el7.x86_64 6/28
Updating : selinux-policy-3.13.1-268.el7_9.2.noarch 7/28
Updating : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 8/28
Installing : libsemanage-python-2.5-14.el7.x86_64 9/28
Installing : audit-libs-python-2.8.5-4.el7.x86_64 10/28
Installing : setools-libs-3.3.8-4.el7.x86_64 11/28
Updating : libselinux-python-2.5-15.el7.x86_64 12/28
Installing : libcgroup-0.41-21.el7.x86_64 13/28
Installing : python-IPy-0.75-6.el7.noarch 14/28
Installing : checkpolicy-2.5-8.el7.x86_64 15/28
Installing : policycoreutils-python-2.5-34.el7.x86_64 16/28
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 17/28
setsebool: SELinux is disabled.
Updating : audit-2.8.5-4.el7.x86_64 18/28
Cleanup : selinux-policy-targeted-3.13.1-192.el7.noarch 19/28
Cleanup : selinux-policy-3.13.1-192.el7.noarch 20/28
Cleanup : policycoreutils-2.5-22.el7.x86_64 21/28
Cleanup : libsemanage-2.5-11.el7.x86_64 22/28
Cleanup : libselinux-utils-2.5-12.el7.x86_64 23/28
Cleanup : libselinux-python-2.5-12.el7.x86_64 24/28
Cleanup : libselinux-2.5-12.el7.x86_64 25/28
Cleanup : audit-2.8.1-3.el7.x86_64 26/28
Cleanup : audit-libs-2.8.1-3.el7.x86_64 27/28
Cleanup : libsepol-2.5-8.1.el7.x86_64 28/28
Verifying : libselinux-2.5-15.el7.x86_64 1/28
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 2/28
Verifying : selinux-policy-3.13.1-268.el7_9.2.noarch 3/28
Verifying : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 4/28
Verifying : audit-libs-2.8.5-4.el7.x86_64 5/28
Verifying : checkpolicy-2.5-8.el7.x86_64 6/28
Verifying : policycoreutils-2.5-34.el7.x86_64 7/28
Verifying : python-IPy-0.75-6.el7.noarch 8/28
Verifying : libselinux-utils-2.5-15.el7.x86_64 9/28
Verifying : policycoreutils-python-2.5-34.el7.x86_64 10/28
Verifying : setools-libs-3.3.8-4.el7.x86_64 11/28
Verifying : audit-2.8.5-4.el7.x86_64 12/28
Verifying : libsemanage-python-2.5-14.el7.x86_64 13/28
Verifying : libsemanage-2.5-14.el7.x86_64 14/28
Verifying : libselinux-python-2.5-15.el7.x86_64 15/28
Verifying : libsepol-2.5-10.el7.x86_64 16/28
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 17/28
Verifying : libcgroup-0.41-21.el7.x86_64 18/28
Verifying : libsemanage-2.5-11.el7.x86_64 19/28
Verifying : libselinux-python-2.5-12.el7.x86_64 20/28
Verifying : audit-libs-2.8.1-3.el7.x86_64 21/28
Verifying : policycoreutils-2.5-22.el7.x86_64 22/28
Verifying : audit-2.8.1-3.el7.x86_64 23/28
Verifying : libsepol-2.5-8.1.el7.x86_64 24/28
Verifying : selinux-policy-3.13.1-192.el7.noarch 25/28
Verifying : libselinux-2.5-12.el7.x86_64 26/28
Verifying : libselinux-utils-2.5-12.el7.x86_64 27/28
Verifying : selinux-policy-targeted-3.13.1-192.el7.noarch 28/28
Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 libselinux.x86_64 0:2.5-15.el7 libselinux-python.x86_64 0:2.5-15.el7 libselinux-utils.x86_64 0:2.5-15.el7
libsemanage.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 policycoreutils.x86_64 0:2.5-34.el7 selinux-policy.noarch 0:3.13.1-268.el7_9.2 selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2
Complete!
此时我们可以重新安装docker-ce
[root@localhost ~]# yum -y install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: ftp.riken.jp
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:24.0.6-1.el7 will be installed
--> Processing Dependency: containerd.io >= 1.6.4 for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-24.0.6-1.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.22-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:24.0.6-1.el7 will be installed
--> Processing Dependency: docker-buildx-plugin for package: 1:docker-ce-cli-24.0.6-1.el7.x86_64
--> Processing Dependency: docker-compose-plugin for package: 1:docker-ce-cli-24.0.6-1.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:24.0.6-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-24.0.6-1.el7.x86_64
--> Running transaction check
---> Package docker-buildx-plugin.x86_64 0:0.11.2-1.el7 will be installed
---> Package docker-compose-plugin.x86_64 0:2.21.0-1.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================================
Installing:
docker-ce x86_64 3:24.0.6-1.el7 docker-ce-stable 24 M
Installing for dependencies:
containerd.io x86_64 1.6.22-3.1.el7 docker-ce-stable 34 M
docker-buildx-plugin x86_64 0.11.2-1.el7 docker-ce-stable 13 M
docker-ce-cli x86_64 1:24.0.6-1.el7 docker-ce-stable 13 M
docker-ce-rootless-extras x86_64 24.0.6-1.el7 docker-ce-stable 9.1 M
docker-compose-plugin x86_64 2.21.0-1.el7 docker-ce-stable 13 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Transaction Summary
======================================================================================================================================================================================================
Install 1 Package (+8 Dependent packages)
Total download size: 107 M
Installed size: 377 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY ] 6.7 MB/s | 35 MB 00:00:10 ETA
Public key for docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm is not installed
(1/9): docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm | 13 MB 00:00:05
(2/9): containerd.io-1.6.22-3.1.el7.x86_64.rpm | 34 MB 00:00:06
(3/9): docker-ce-cli-24.0.6-1.el7.x86_64.rpm | 13 MB 00:00:02
(4/9): docker-ce-rootless-extras-24.0.6-1.el7.x86_64.rpm | 9.1 MB 00:00:01
(5/9): docker-ce-24.0.6-1.el7.x86_64.rpm | 24 MB 00:00:05
(6/9): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(7/9): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(8/9): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(9/9): docker-compose-plugin-2.21.0-1.el7.x86_64.rpm | 13 MB 00:00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.5 MB/s | 107 MB 00:00:12
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-buildx-plugin-0.11.2-1.el7.x86_64 1/9
Installing : containerd.io-1.6.22-3.1.el7.x86_64 2/9
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 3/9
Installing : docker-compose-plugin-2.21.0-1.el7.x86_64 4/9
Installing : 1:docker-ce-cli-24.0.6-1.el7.x86_64 5/9
Installing : fuse3-libs-3.6.1-4.el7.x86_64 6/9
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 7/9
Installing : 3:docker-ce-24.0.6-1.el7.x86_64 8/9
Installing : docker-ce-rootless-extras-24.0.6-1.el7.x86_64 9/9
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 1/9
Verifying : docker-compose-plugin-2.21.0-1.el7.x86_64 2/9
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 3/9
Verifying : docker-ce-rootless-extras-24.0.6-1.el7.x86_64 4/9
Verifying : 3:docker-ce-24.0.6-1.el7.x86_64 5/9
Verifying : containerd.io-1.6.22-3.1.el7.x86_64 6/9
Verifying : docker-buildx-plugin-0.11.2-1.el7.x86_64 7/9
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 8/9
Verifying : 1:docker-ce-cli-24.0.6-1.el7.x86_64 9/9
Installed:
docker-ce.x86_64 3:24.0.6-1.el7
Dependency Installed:
containerd.io.x86_64 0:1.6.22-3.1.el7 docker-buildx-plugin.x86_64 0:0.11.2-1.el7 docker-ce-cli.x86_64 1:24.0.6-1.el7 docker-ce-rootless-extras.x86_64 0:24.0.6-1.el7
docker-compose-plugin.x86_64 0:2.21.0-1.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
这里我们设置docker开机自启动
[root@localhost ~]# systemctl enable docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# 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 Sat 2023-09-09 12:40:28 CST; 12s ago
Docs: https://docs.docker.com
Main PID: 10026 (dockerd)
Tasks: 10
Memory: 29.8M
CGroup: /system.slice/docker.service
└─10026 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Sep 09 12:40:27 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Sep 09 12:40:27 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:27.757791881+08:00" level=info msg="Starting up"
Sep 09 12:40:27 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:27.801731907+08:00" level=info msg="Loading containers: start."
Sep 09 12:40:27 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:27.952186968+08:00" level=info msg="Loading containers: done."
Sep 09 12:40:27 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:27.986552547+08:00" level=info msg="Docker daemon" commit=1a79695 graphdriver=overlay2 version=24.0.6
Sep 09 12:40:27 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:27.986619633+08:00" level=info msg="Daemon has completed initialization"
Sep 09 12:40:28 localhost.localdomain dockerd[10026]: time="2023-09-09T12:40:28.002652354+08:00" level=info msg="API listen on /run/docker.sock"
Sep 09 12:40:28 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
我们可以看见,此时的docker是最新版
[root@localhost ~]# docker --version
Docker version 24.0.6, build ed223bc
[root@localhost ~]# docker version
Client: Docker Engine - Community
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:35:25 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:34:28 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
搭建nextcloud网盘有两种方法
方法1:通过docker-compose.yml的方式安装。
方法2: 通过docker命令安装。
这里重点讲解方法2,方法1只将docker-compose的安装方法
[root@localhost ~]# curl -SL https://github.com/docker/compose/releases/download/v2.19.1/docker-compose-`uname -s`-`uname -r` -o /usr/local/bin/docker-compose
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose
下载完成之后上传到服务器的/usr/local/bin/并修改名称为docker-compose,且需要给/usr/local/bin/docker-compose执行权限。
输入阿里云镜像加速页面这个网址进入阿里云的镜像加载页面,之后点击下方的镜像工具,点击镜像加速器,在选择centos将下面的命令复制粘贴执行即可。
我们需要下载nextcloud和mysql这两个镜像。
[root@localhost ~]# docker pull nextcloud
Using default tag: latest
latest: Pulling from library/nextcloud
a2abf6c4d29d: Pull complete
c5608244554d: Pull complete
2d07066487a0: Pull complete
1b6dfaf1958c: Pull complete
32c5e6a60073: Pull complete
90cf855b27cc: Pull complete
8b0f1068c586: Pull complete
53530861540e: Pull complete
b088256e8218: Pull complete
29c48e642f3d: Pull complete
bebfd59a832e: Pull complete
3c07d6be5322: Pull complete
52a174ca2213: Pull complete
2db451f4f766: Pull complete
462c9168620c: Pull complete
5f6a7ae88b1d: Pull complete
8507904d39d6: Pull complete
f6dc5bb9d193: Pull complete
d57202c49578: Pull complete
57f778f1c66e: Pull complete
Digest: sha256:bd3406506335b6621b1eb7a3d897654ac7963e3db4b91cbea3436f159655d0ba
Status: Downloaded newer image for nextcloud:latest
docker.io/library/nextcloud:latest
[root@localhost ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
72a69066d2fe: Pull complete
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
688ba7d5c01a: Pull complete
00e060b6d11d: Pull complete
1c04857f594f: Pull complete
4d7cfa90e6ea: Pull complete
e0431212d27d: Pull complete
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nextcloud latest c805c152803c 20 months ago 969MB
mysql latest 3218b38490ce 20 months ago 516MB
[root@localhost ~]# mkdir /home/{mysql,nextcloud}
[root@localhost ~]# mkdir /home/mysql/{data,log}
[root@localhost ~]# mkdir /home/nextcloud/html
docker run:启动容器的命令
-d:在后台运行容器
-p 8080:80 :设置容器的映射端口(宿主机端口:容器内应用端口)
–name=nextcloud:设置容器名字
–restart=always:设置开机自启动(代表只要docker重启,容器也跟着重启)
–network=bridge:设置网络模式(brideg代表NAT模式)
-v /home/nextcloud/html/:/var/www/html:设置数据持久化目录(宿主机目录:容器内目录)
nextcloud:镜像名
[root@localhost ~]# docker run -d -p 8080:80 --name=nextcloud --restart=always --network=bridge -v /home/nextcloud/html/:/var/www/html nextcloud
11c66914f2e88b1ba1404d832fff8df921fe10e8faec7b90ac963ca7e8a96c59
[root@localhost ~]# docker run -d -p 3306:3306 --name=mysql-nextcloud --restart=always --network=bridge -e MYSQL_ROOT_PASSWORD=1 -v /home/mysql/data/:/var/lib/mysql -v /home/mysql/log/:/var/log/mysql mysql
28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
28da618d12c2 mysql "docker-entrypoint.s…" 23 seconds ago Up 22 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql-nextcloud
11c66914f2e8 nextcloud "/entrypoint.sh apac…" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp, :::8080->80/tcp nextcloud
进入到mysql-nextcloud容器中在创建数据库并创建用户设置权限。(创建用户的同时需要设置登录权限)
库名:nextcloud
用户名:nextcloud
密码:nextcloud
[root@localhost ~]# docker exec -it mysql-nextcloud bash
root@28da618d12c2:/# mysql -uroot -p1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database nextcloud;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'nextcloud'@'%' identified by 'nextcloud';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on nextcloud.* to 'nextcloud'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
打开浏览器输入192.168.1.3:8080。
这里输入的docker的IP地址,应为我们把容器的端口映射出来了,宿主机的监听端口是8080
通过下面命令查看mysql-nextcloud的IP是多少
[root@localhost ~]# docker inspect mysql-nextcloud
[
{
"Id": "28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505",
"Created": "2023-09-09T06:23:25.268909004Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mysqld"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 43743,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-09-09T06:23:25.521976509Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:3218b38490cec8d31976a40b92e09d61377359eab878db49f025e5d464367f3b",
"ResolvConfPath": "/var/lib/docker/containers/28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505/hostname",
"HostsPath": "/var/lib/docker/containers/28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505/hosts",
"LogPath": "/var/lib/docker/containers/28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505/28da618d12c2c7d658ebab1e922cd45db0d9e29f1f23912c2004f7c410d62505-json.log",
"Name": "/mysql-nextcloud",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/mysql/data/:/var/lib/mysql",
"/home/mysql/log/:/var/log/mysql"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"3306/tcp": [
{
"HostIp": "",
"HostPort": "3306"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
60,
198
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/876c340438ae4ead5c7e53029b4ceaac3ad3f8bec8b146750378bbd31c10cf87-init/diff:/var/lib/docker/overlay2/d60b11fa66ee79d71fa30c1646455e5869a8f10110187bb892d67ab0a2694277/diff:/var/lib/docker/overlay2/8286efbbb289a427b4036ee01f086b030f4c89672a6af13b980058e4cef38ba2/diff:/var/lib/docker/overlay2/257f6d11db1974fc20dd3cacf3cfcb5b0b71a7060be14c2e5b31d14477b35b6d/diff:/var/lib/docker/overlay2/df317ecc700d2ae1c1b2f06c462eb350cecee76b1309009a1754593654759d26/diff:/var/lib/docker/overlay2/7d0de5a9f8a1593dfa00579db77ee82b071f66d69e18581cae4e5032093a1516/diff:/var/lib/docker/overlay2/902cc62a7896ff7ffc250341e1f844debeb01e7b4aacc150911c6588ba005aa1/diff:/var/lib/docker/overlay2/388b4c5137adaac9a5e18c5b20efaadd0126ee47203a8fe067342fe1469bfc69/diff:/var/lib/docker/overlay2/ccb9b374c56fa7bf459b2ed1f4fb668c189668aab43bbffe288911f293470542/diff:/var/lib/docker/overlay2/37509308b5811d96d09dcec774f229a8acddad8568d99d1ff9e33122cfdad07c/diff:/var/lib/docker/overlay2/17a7a86eb3e48ef2be56d71192ecafe2ee29488f591591aa43e64b5ce4a7eb9b/diff:/var/lib/docker/overlay2/4632e307cf38e6f28decb2b103a0a8e37d4c1c01c21dc1fbeb67153831aa40be/diff:/var/lib/docker/overlay2/c6f821c799e77cc3dd300cfcb28ea35f5c4c995c3eef8adb27abd37e56d4c242/diff",
"MergedDir": "/var/lib/docker/overlay2/876c340438ae4ead5c7e53029b4ceaac3ad3f8bec8b146750378bbd31c10cf87/merged",
"UpperDir": "/var/lib/docker/overlay2/876c340438ae4ead5c7e53029b4ceaac3ad3f8bec8b146750378bbd31c10cf87/diff",
"WorkDir": "/var/lib/docker/overlay2/876c340438ae4ead5c7e53029b4ceaac3ad3f8bec8b146750378bbd31c10cf87/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/mysql/data",
"Destination": "/var/lib/mysql",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/home/mysql/log",
"Destination": "/var/log/mysql",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "28da618d12c2",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=1",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.12",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.27-1debian10"
],
"Cmd": [
"mysqld"
],
"Image": "mysql",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "e25be2edf64e58da4c95fcbdddf9419d50fef103ac080c6a9aea7f624bde8ee2",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3306"
},
{
"HostIp": "::",
"HostPort": "3306"
}
],
"33060/tcp": null
},
"SandboxKey": "/var/run/docker/netns/e25be2edf64e",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "bbba6e19d7a43607a948284ffd52d780c6ff8b15f94cef7b64d9b0c0d258a5cf",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "07bd3f98add3dd08efefe2761b1ff61e959ea91b144c54976bb41eae3ae977b3",
"EndpointID": "bbba6e19d7a43607a948284ffd52d780c6ff8b15f94cef7b64d9b0c0d258a5cf",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]
首先创建一个管理账号(名称随便)
在选择mysql数据库,将刚才创建的库和用于和库连接的用户名和IP输入。
点击安装完成之后就开始安装
依次输入登录用户名、显示用户名、登录密码、电子邮箱(电子邮箱可以不输入,但是找回密码时使用的是电子邮箱)、输入分组、选择是否是这个分组的管理员、设置网盘存储大小。
此时我们就可以看见刚才创建的用户了。
首先点击头像,点击settings
点击图中红框处,选择中文即可。
首先创建数据持久化目录,在运行容器并将主目录挂载到数据持久化目录。
[root@localhost ~]# mkdir -p /tmp/test/nextcloud
[root@localhost ~]# docker run -d -p 8081:80 --name=test --restart=always --network=bridge -v /tmp/test/nextcloud/:/var/www/html nextcloud
9b8b46a073167c9f93c6d7a29b181e19bd8f0bb79fbf76430709e7e5029c20b2
此时我们看见容器已经运行成功了
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9b8b46a07316 nextcloud "/entrypoint.sh apac…" 28 seconds ago Up 27 seconds 0.0.0.0:8081->80/tcp, :::8081->80/tcp test
28da618d12c2 mysql "docker-entrypoint.s…" 17 minutes ago Up 16 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql-nextcloud
11c66914f2e8 nextcloud "/entrypoint.sh apac…" 18 minutes ago Up 18 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp nextcloud
首先删除刚才新创建容器的主目录数据,在将之前容器的主目录复制到新容器主目录位置。
[root@localhost ~]# cd /tmp/test/nextcloud/
[root@localhost nextcloud]# rm -rf *
[root@localhost nextcloud]# cp -r /home/nextcloud/html/* .
复制完成数据之后需要进入容器中修改目录的属主。(目录的属主是www-data)
[root@localhost nextcloud]# docker exec -it test bash
root@9b8b46a07316:/var/www/html# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
root@9b8b46a07316:/var/www/html# chown -R www-data ./
如果不删除日志会报错。
[root@localhost ~]# cd /tmp/test/nextcloud/
[root@localhost nextcloud]# vim data/nextcloud.log
{"reqId":"hhDuvD02EIqlwqwfjCyy","level":2,"time":"2023-09-09T06:26:10+00:00","remoteAddr":"192.168.1.1","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":""}
{"reqId":"hhDuvD02EIqlwqwfjCyy","level":2,"time":"2023-09-09T06:26:10+00:00","remoteAddr":"192.168.1.1","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":""}
{"reqId":"JgWwJOTUN85VixzE3oUV","level":2,"time":"2023-09-09T06:28:45+00:00","remoteAddr":"192.168.1.1","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":""}
{"reqId":"JgWwJOTUN85VixzE3oUV","level":2,"time":"2023-09-09T06:28:45+00:00","remoteAddr":"192.168.1.1","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":""}
{"reqId":"JgWwJOTUN85VixzE3oUV","level":2,"time":"2023-09-09T06:29:56+00:00","remoteAddr":"192.168.1.1","user":"--","app":"appstoreFetcher","method":"POST","url":"/index.php","message":"Could not connect to appstore: cURL error 28: Operation timed out after 60000 milliseconds with 917504 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://apps.nextcloud.com/api/v1/apps.json","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":"23.0.0.10"}
{"reqId":"mgHLTVnnAZSDRbPECThb","level":2,"time":"2023-09-09T06:34:58+00:00","remoteAddr":"192.168.1.1","user":"admin","app":"ocs_api","method":"POST","url":"/ocs/v2.php/cloud/users","message":"Failed addUser attempt with hint exception.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.9011 SLBChan/103","version":"23.0.0.10","exception":{"Exception":"OC\\HintException","Message":"Password is present in compromised password list. Please choose a different password.","Code":0,"Trace":[{"file":"/var/www/html/apps/password_policy/lib/Listener/ValidatePasswordPolicyEventListener.php","line":46,"function":"validate","class":"OCA\\Password_Policy\\PasswordValidator","type":"->","args":["*** sensitive parameter replaced ***"]},{"file":"/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php","line":87,"function":"handle","class":"OCA\\Password_Policy\\Listener\\ValidatePasswordPolicyEventListener","type":"->","args":[{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"}]},{"file":"/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->","args":[{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"},"OCP\\Security\\Events\\ValidatePasswordPolicyEvent",{"__class__":"Symfony\\Component\\EventDispatcher\\EventDispatcher"}]},{"file":"/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[[{"__class__":"Closure"}],"OCP\\Security\\Events\\ValidatePasswordPolicyEvent",{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"}]},{"file":"/var/www/html/lib/private/EventDispatcher/EventDispatcher.php","line":88,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"},"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"]},{"file":"/var/www/html/lib/private/EventDispatcher/EventDispatcher.php","line":100,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":["OCP\\Security\\Events\\ValidatePasswordPolicyEvent",{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"}]},{"file":"/var/www/html/lib/private/User/Database.php","line":123,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\Security\\Events\\ValidatePasswordPolicyEvent"}]},{"file":"/var/www/html/lib/private/User/Manager.php","line":463,"function":"createUser","class":"OC\\User\\Database","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/var/www/html/lib/private/User/Manager.php","line":407,"function":"createUserFromBackend","class":"OC\\User\\Manager","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***",{"__class__":"OC\\User\\Database"}]},{"file":"/var/www/html/apps/provisioning_api/lib/Controller/UsersController.php","line":417,"function":"createUser","class":"OC\\User\\Manager","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"addUser","class":"OCA\\Provisioning_API\\Controller\\UsersController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Provisioning_API\\Controller\\UsersController"},"addUser"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Provisioning_API\\Controller\\UsersController"},"addUser"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Provisioning_API\\Controller\\UsersController","addUser",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.provisioning_api.Users.addUser"}]},{"file":"/var/www/html/ocs/v1.php","line":62,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/cloud/users"]},{"file":"/var/www/html/ocs/v2.php","line":23,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/apps/password_policy/lib/PasswordValidator.php","Line":87,"Hint":"\u8be5\u5bc6\u7801\u5728\u7981\u7528\u7684\u5bc6\u7801\u5217\u8868\u4e2d\uff0c\u8bf7\u9009\u62e9\u5176\u4ed6\u5bc6\u7801\u3002","CustomMessage":"Failed addUser attempt with hint exception."}}
这里我们需要修改相应的数据库IP和访问IP端口(这里的数据库是同一个,不需要修改,只修改端口即可)
[root@localhost nextcloud]# vim config/config.php
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
0 =>
array (
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
),
),
'instanceid' => 'oc2g8h7hpzva',
'passwordsalt' => '6uRSBfeiCxeumuFhUVpMvoZpyiaS+a',
'secret' => 'Wn8+UEPxW/AxGTkLJ13k/ubON2mTTBvtS0vdwvMpo7orU+QO',
'trusted_domains' =>
array (
0 => '192.168.1.3:8081',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'mysql',
'version' => '23.0.0.10',
'overwrite.cli.url' => 'http://192.168.1.3:8081',
'dbname' => 'nextcloud',
'dbhost' => '172.17.0.3',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'nextcloud',
'installed' => true,
);
[root@localhost ~]# docker restart test
test
此时我们登录之前创建的用户:test123
打开文件之后发现我们在前一个容器中创建的文件在新的容器中可以查看到,表示数据迁移成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。