一、查询系统配置
下单购买的选的是CentOS7系统,单核CPU, 2G内存,习惯性看一下系统配置。
- 查询系统版本
[root@iZwz9g9147kb7e72a0rsg3Z ~]# 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"
- 查询CPU详细信息
[root@iZwz9g9147kb7e72a0rsg3Z ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
stepping : 1
microcode : 0x1
cpu MHz : 2499.994
cache size : 40960 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat spec_ctrl intel_stibp
bogomips : 4999.98
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
- 查询内存信息
[root@iZwz9g9147kb7e72a0rsg3Z ~]# free -m
total used free shared buff/cache available
Mem: 1837 133 1501 0 202 1564
Swap: 0 0 0
二、安装docker
- 卸载已安装docker,新的ECS服务器嘛,自然是没安装过的。
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
- 安装yum-utils工具包, 因为需要使用yum-config-manager增加yum的docker社区版仓库,不然yum会找不到docker。
Tips:
Yellow dog Updater, Modified(Yum),是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。
yum-config-manager是一个命令。包含在yum-utils这个包内。即,安装yum-utils之后才能运行yum-config-manager命令
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo yum install -y yum-utils
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 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/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/7): epel/x86_64/group_gz | 96 kB 00:00:00
(3/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(4/7): extras/7/x86_64/primary_db | 236 kB 00:00:00
(5/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(6/7): epel/x86_64/primary_db | 6.9 MB 00:00:00
(7/7): updates/7/x86_64/primary_db | 8.0 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7.5 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7.5 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 863 k
Installed size: 4.3 M
Downloading packages:
(1/4): libxml2-python-2.9.1-6.el7.5.x86_64.rpm | 247 kB 00:00:00
(2/4): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
(3/4): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
(4/4): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.8 MB/s | 863 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-chardet-2.2.1-3.el7.noarch 1/4
Installing : python-kitchen-1.1.1-5.el7.noarch 2/4
Installing : libxml2-python-2.9.1-6.el7.5.x86_64 3/4
Installing : yum-utils-1.1.31-54.el7_8.noarch 4/4
Verifying : libxml2-python-2.9.1-6.el7.5.x86_64 1/4
Verifying : python-kitchen-1.1.1-5.el7.noarch 2/4
Verifying : yum-utils-1.1.31-54.el7_8.noarch 3/4
Verifying : python-chardet-2.2.1-3.el7.noarch 4/4
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7.5 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
Complete!
- 配置docker社区版仓库到yum
[root@iZwz9g9147kb7e72a0rsg3Z ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://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社区版,一直按y就好
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 60 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.6-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.6-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.6-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.6-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.6-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.6-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.6-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.6-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.6-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.6-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.7.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> 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 policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> 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: 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 slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> 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
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
containerd.io x86_64 1.4.6-3.1.el7 docker-ce-stable 34 M
docker-ce x86_64 3:20.10.6-3.el7 docker-ce-stable 27 M
docker-ce-cli x86_64 1:20.10.6-3.el7 docker-ce-stable 33 M
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
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras x86_64 20.10.6-3.el7 docker-ce-stable 9.2 M
docker-scan-plugin x86_64 0.7.0-3.el7 docker-ce-stable 4.2 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
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
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Transaction Summary
=============================================================================================================================================================================================
Install 3 Packages (+13 Dependent packages)
Total download size: 108 M
Installed size: 444 M
Is this ok [y/d/N]: y
Downloading packages:
(1/16): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(2/16): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(3/16): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.6-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY ] 7.2 MB/s | 50 MB 00:00:08 ETA
Public key for docker-ce-20.10.6-3.el7.x86_64.rpm is not installed
(4/16): docker-ce-20.10.6-3.el7.x86_64.rpm | 27 MB 00:00:05
(5/16): containerd.io-1.4.6-3.1.el7.x86_64.rpm | 34 MB 00:00:07
(6/16): docker-ce-rootless-extras-20.10.6-3.el7.x86_64.rpm | 9.2 MB 00:00:01
(7/16): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(8/16): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(9/16): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(10/16): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(11/16): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(12/16): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(13/16): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(14/16): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(15/16): docker-scan-plugin-0.7.0-3.el7.x86_64.rpm | 4.2 MB 00:00:00
(16/16): docker-ce-cli-20.10.6-3.el7.x86_64.rpm | 33 MB 00:00:07
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.0 MB/s | 108 MB 00:00:13
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
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-21.el7.x86_64 1/16
Installing : 1:docker-ce-cli-20.10.6-3.el7.x86_64 2/16
Installing : docker-scan-plugin-0.7.0-3.el7.x86_64 3/16
Installing : setools-libs-3.3.8-4.el7.x86_64 4/16
Installing : audit-libs-python-2.8.5-4.el7.x86_64 5/16
Installing : checkpolicy-2.5-8.el7.x86_64 6/16
Installing : python-IPy-0.75-6.el7.noarch 7/16
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 8/16
Installing : fuse3-libs-3.6.1-4.el7.x86_64 9/16
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 10/16
Installing : libsemanage-python-2.5-14.el7.x86_64 11/16
Installing : policycoreutils-python-2.5-34.el7.x86_64 12/16
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 13/16
setsebool: SELinux is disabled.
Installing : containerd.io-1.4.6-3.1.el7.x86_64 14/16
Installing : docker-ce-rootless-extras-20.10.6-3.el7.x86_64 15/16
Installing : 3:docker-ce-20.10.6-3.el7.x86_64 16/16
Verifying : containerd.io-1.4.6-3.1.el7.x86_64 1/16
Verifying : libsemanage-python-2.5-14.el7.x86_64 2/16
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 3/16
Verifying : docker-ce-rootless-extras-20.10.6-3.el7.x86_64 4/16
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 5/16
Verifying : policycoreutils-python-2.5-34.el7.x86_64 6/16
Verifying : 3:docker-ce-20.10.6-3.el7.x86_64 7/16
Verifying : docker-scan-plugin-0.7.0-3.el7.x86_64 8/16
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 9/16
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 10/16
Verifying : python-IPy-0.75-6.el7.noarch 11/16
Verifying : checkpolicy-2.5-8.el7.x86_64 12/16
Verifying : 1:docker-ce-cli-20.10.6-3.el7.x86_64 13/16
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 14/16
Verifying : setools-libs-3.3.8-4.el7.x86_64 15/16
Verifying : libcgroup-0.41-21.el7.x86_64 16/16
Installed:
containerd.io.x86_64 0:1.4.6-3.1.el7 docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-cli.x86_64 1:20.10.6-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.6-3.el7
docker-scan-plugin.x86_64 0:0.7.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.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
slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
三、启动docker
安装好之后,当然是要启动的试试拉
- 启动,然后查一下服务状态
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo systemctl start docker
[root@iZwz9g9147kb7e72a0rsg3Z ~]# 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 Sat 2021-05-29 18:00:31 CST; 27s ago
Docs: https://docs.docker.com
Main PID: 11547 (dockerd)
Tasks: 8
Memory: 43.4M
CGroup: /system.slice/docker.service
└─11547 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.367553273+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.367567448+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/cont...module=grpc
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.367577233+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.431587283+08:00" level=info msg="Loading containers: start."
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.771315900+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172....IP address"
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.839503428+08:00" level=info msg="Loading containers: done."
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.868861156+08:00" level=info msg="Docker daemon" commit=8728dd2 graphdriver(s)=overlay2 version=20.10.6
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.868993816+08:00" level=info msg="Daemon has completed initialization"
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z systemd[1]: Started Docker Application Container Engine.
May 29 18:00:31 iZwz9g9147kb7e72a0rsg3Z dockerd[11547]: time="2021-05-29T18:00:31.920292605+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
2.没问题之后,跑个经典的hellworld测试
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
四、docker镜像加速
由于众所周知的原因,在国内拉取国外的docker镜像时,速度会很慢,甚至失败。所以配置docker读取国内镜像仓库拉去镜像,既然是阿里云的服务器,当然使用阿里云的镜像加速。
-
登录容器镜像服务控制台后,在左侧导航栏选择镜像工具 > 镜像加速器,在镜像加速器页面就会显示为您独立分配的加速器地址
-
配置镜像加速器
阿里云文档原话:
当您下载安装的Docker Version不低于1.10时,建议直接通过daemon config进行配置。使用配置文件/etc/docker/daemon.json(没有时新建该文件)。
{
“registry-mirrors”: [""]
}
检查一下docker版本
[root@iZwz9g9147kb7e72a0rsg3Z ~]# docker --version
Docker version 20.10.6, build 370c289
新建daemon配置文件/etc/docker/daemon.json来使用加速器
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://xxxxxxx.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://xxxxxxx.mirror.aliyuncs.com"]
}
重载新配置,然后重启docker
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo systemctl daemon-reload
[root@iZwz9g9147kb7e72a0rsg3Z ~]# sudo systemctl restart docker
拉取mysql镜像测试一下是否正常,以及镜像拉取速度
[root@iZwz9g9147kb7e72a0rsg3Z ~]# time docker pull mysql:5.7
5.7: Pulling from library/mysql
69692152171a: Pull complete
1651b0be3df3: Pull complete
951da7386bc8: Pull complete
0f86c95aa242: Pull complete
37ba2d8bd4fe: Pull complete
6d278bb05e94: Pull complete
497efbd93a3e: Pull complete
a023ae82eef5: Pull complete
e76c35f20ee7: Pull complete
e887524d2ef9: Pull complete
ccb65627e1c3: Pull complete
Digest: sha256:a682e3c78fc5bd941e9db080b4796c75f69a28a8cad65677c23f7a9f18ba21fa
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
real 0m31.178s
user 0m0.046s
sys 0m0.040s