Centos Docker Configuration Overview

Coordinates a school in Nanjing. Campus Network Configuration Docker needs to configure a proxy server. From 2 p.m. to 19.38 p.m., make a note to mak...

Coordinates a school in Nanjing.

Campus Network Configuration Docker needs to configure a proxy server.

From 2 p.m. to 19.38 p.m., make a note to make it easier for future classmates to take less detours.

1 yum mirror source configuration

If Step 2 runs straight, you don't need it, but you can go straight to Step 2.

Change the yum source to mirrors.163.com

(1) Backup the original yum source of the system

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2) Enter the folder

# cd /etc/yum.repos.d/

(3) Download a new yum source profile to this folder. For centos7, the command is

# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

(Other centos systems change 7 to the corresponding version number)

(4) Generate cache

# yum makecache

(5) Update system

# yum -y update

Update a bunch of things to display

zenity.x86_64 0:3.28.1-1.el7 zlib.x86_64 0:1.2.7-18.el7 Replaced: caribou.x86_64 0:0.4.21-1.el7 caribou-gtk2-module.x86_64 0:0.4.21-1.el7 caribou-gtk3-module.x86_64 0:0.4.21-1.el7 gnome-dictionary-libs.x86_64 0:3.20.0-1.el7 gnome-tweak-tool.noarch 0:3.22.0-1.el7 grub2.x86_64 1:2.02-0.65.el7.centos.2 grub2-tools.x86_64 1:2.02-0.65.el7.centos.2 mesa-libwayland-egl.x86_64 0:17.2.3-8.20171019.el7 pyatspi.noarch 0:2.20.3-1.el7 python2-caribou.noarch 0:0.4.21-1.el7 Complete!

2Once you have configured the yum mirror source, you can install Docker

(1) yum installation

[root@localhost yum.repos.d]# yum install -y yum-utils device-mapper-persistent-data lvm2Loaded plugins: fastestmirror, langpacks Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: ap.stykers.moe * extras: mirrors.nju.edu.cn * updates: ftp.sjtu.edu.cn base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Package yum-utils-1.1.31-50.el7.noarch already installed and latest version Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version Package 7:lvm2-2.02.180-10.el7_6.7.x86_64 already installed and latest version Nothing to do

(2) Replace this with an aliyun scene

[root@localhost yum.repos.d]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo Loaded plugins: fastestmirror, langpacks Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration 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

(3) Start docker CE installation

[root@localhost yum.repos.d]# yum makecache fast Loaded plugins: fastestmirror, langpacks Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: ap.stykers.moe * extras: mirrors.nju.edu.cn * updates: ftp.sjtu.edu.cn base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:01 (2/2): docker-ce-stable/x86_64/primary_db | 28 kB 00:00:01 Metadata Cache Created
[root@localhost yum.repos.d]# yum -y install docker-ceLoaded plugins: fastestmirror, langpacks Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: ap.stykers.moe * extras: mirrors.nju.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 3:18.09.6-3.el7 will be installed --> Processing Dependency: container-selinux >= 2.9 for package: 3:docker-ce-18.09.6-3.el7.x86_64 --> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.6-3.el7.x86_64 --> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.6-3.el7.x86_64 --> Running transaction check ---> Package container-selinux.noarch 2:2.95-2.el7_6 will be installed ---> Package containerd.io.x86_64 0:1.2.5-3.1.el7 will be installed ---> Package docker-ce-cli.x86_64 1:18.09.6-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================== Package Arch Version Repository Size ============================================================================================== Installing: docker-ce x86_64 3:18.09.6-3.el7 docker-ce-stable 19 M Installing for dependencies: container-selinux noarch 2:2.95-2.el7_6 extras 39 k containerd.io x86_64 1.2.5-3.1.el7 docker-ce-stable 22 M docker-ce-cli x86_64 1:18.09.6-3.el7 docker-ce-stable 14 M Transaction Summary ============================================================================================== Install 1 Package (+3 Dependent packages) Total download size: 55 M Installed size: 236 M Downloading packages: (1/4): container-selinux-2.95-2.el7_6.noarch.rpm | 39 kB 00:00:00 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.6-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Public key for docker-ce-18.09.6-3.el7.x86_64.rpm is not installed (2/4): docker-ce-18.09.6-3.el7.x86_64.rpm | 19 MB 00:00:53 (3/4): containerd.io-1.2.5-3.1.el7.x86_64.rpm | 22 MB 00:01:16 (4/4): docker-ce-cli-18.09.6-3.el7.x86_64.rpm | 14 MB 00:00:32 ---------------------------------------------------------------------------------------------- Total 648 kB/s | 55 MB 00:01:26 Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <[email protected]>" 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 : 1:docker-ce-cli-18.09.6-3.el7.x86_64 1/4 Installing : containerd.io-1.2.5-3.1.el7.x86_64 2/4 Installing : 2:container-selinux-2.95-2.el7_6.noarch 3/4 Installing : 3:docker-ce-18.09.6-3.el7.x86_64 4/4 Verifying : 2:container-selinux-2.95-2.el7_6.noarch 1/4 Verifying : containerd.io-1.2.5-3.1.el7.x86_64 2/4 Verifying : 3:docker-ce-18.09.6-3.el7.x86_64 3/4 Verifying : 1:docker-ce-cli-18.09.6-3.el7.x86_64 4/4 Installed: docker-ce.x86_64 3:18.09.6-3.el7 Dependency Installed: container-selinux.noarch 2:2.95-2.el7_6 containerd.io.x86_64 0:1.2.5-3.1.el7 docker-ce-cli.x86_64 1:18.09.6-3.el7 Complete!

The result is successful installation!!!!But the campus network also has to configure the proxy inside the docker

(4) View docker version

[root@localhost yum.repos.d]# docker version Client: Version: 18.09.6 API version: 1.39 Go version: go1.10.8 Git commit: 481bc77156 Built: Sat May 4 02:34:58 2019 OS/Arch: linux/amd64 Experimental: false Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

(5) Open docker

[root@localhost yum.repos.d]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@localhost yum.repos.d]# sudo systemctl start docker

(6) Test whether docker is installed correctly

[root@localhost yum.repos.d]# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'.

(7) We did not install it correctly here because of the problem of the campus network....This starts the Docker internal proxy setup, referring to: https://www.cnblogs.com/wuyuxin/p/7041400.html , uses the solution three here.You can move on to understand!Then you can!!!!

[root@localhost yum.repos.d]# mkdir -p /etc/systemd/system/docker.service.d [root@localhost yum.repos.d]# vi /etc/systemd/system/docker.service.d/http-proxy.conf [root@localhost yum.repos.d]# systemctl daemon-reload [root@localhost yum.repos.d]# systemctl restart docker [root@localhost yum.repos.d]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:6f744a2005b12a704d2608d8070a494ad1145636eeb74a570c56b94d94ccdbfc 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/

Reference material:

https://blog.csdn.net/inslow/article/details/54177191

https://blog.csdn.net/weixin_34406796/article/details/88486271

https://www.cnblogs.com/wuyuxin/p/7041400.html

7 November 2019, 09:57 | Views: 4529

Add new comment

For adding a comment, please log in
or create account

0 comments