# **Installation of Docker and how to configure and drag the required images from the domestic image to local use**
lab environment:
OS: CentOS7.0 -X64
Internet access environment: Internet access through a proxy server
1. First download the docker installation package
Download the required plugins for docker installation:
docker-engine-selinux-1.9.1-1.e17.centos.noarch.rpm
Download address: http://yum.dockerproject.org/repo/main/centos/7/Packages/
docker-engine-1.9.1.1.e17.centos.x86_64.rpm
Download address: http://yum.dockerproject.org/repo/main/centos/7/Packages/
2. Install docker
Check out the downloaded installation package first:
[root@docker docker]# pwd
/docker
[root@docker docker]# ls
docker-engine-1.9.1-1.el7.centos.x86_64.rpm docker-engine-selinux-1.9.1-1.el7.centos.noarch.rpm
[root@docker docker]# rpm -ivh docker-engine*
warning: docker-engine-1.9.1-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
error: Failed dependencies:
policycoreutils-python is needed by docker-engine-selinux-1.9.1-1.el7.centos.noarch
The installation prompts that the policycoreutils-python component is missing
[root@docker docker]# yum install -y policycoreutils-python (You can install this component directly from the CD-ROM yum source)
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-17.1.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-5 for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-17.1.el7.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.7.6-3.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-8.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-1.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================
Package Arch Version Repository Size
==================================================================================================================
Installing:
policycoreutils-python x86_64 2.5-17.1.el7 c7-media 446 k
Installing for dependencies:
audit-libs-python x86_64 2.7.6-3.el7 c7-media 73 k
checkpolicy x86_64 2.5-4.el7 c7-media 290 k
libsemanage-python x86_64 2.5-8.el7 c7-media 104 k
python-IPy noarch 0.75-6.el7 c7-media 32 k
setools-libs x86_64 3.3.8-1.1.el7 c7-media 612 k
Transaction Summary
==================================================================================================================
Install 1 Package (+5 Dependent packages)
Total download size: 1.5 M
Installed size: 5.0 M
Downloading packages:
------------------------------------------------------------------------------------------------------------------
Total 4.8 MB/s | 1.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : checkpolicy-2.5-4.el7.x86_64 1/6
Installing : setools-libs-3.3.8-1.1.el7.x86_64 2/6
Installing : python-IPy-0.75-6.el7.noarch 3/6
Installing : audit-libs-python-2.7.6-3.el7.x86_64 4/6
Installing : libsemanage-python-2.5-8.el7.x86_64 5/6
Installing : policycoreutils-python-2.5-17.1.el7.x86_64 6/6
Verifying : libsemanage-python-2.5-8.el7.x86_64 1/6
Verifying : audit-libs-python-2.7.6-3.el7.x86_64 2/6
Verifying : python-IPy-0.75-6.el7.noarch 3/6
Verifying : policycoreutils-python-2.5-17.1.el7.x86_64 4/6
Verifying : setools-libs-3.3.8-1.1.el7.x86_64 5/6
Verifying : checkpolicy-2.5-4.el7.x86_64 6/6
Installed:
policycoreutils-python.x86_64 0:2.5-17.1.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7
libsemanage-python.x86_64 0:2.5-8.el7 python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-1.1.el7
Complete!
[root@docker docker]# rpm -ivh docker-engine* Install docker again, successfully installed
warning: docker-engine-1.9.1-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:docker-engine-selinux-1.9.1-1.el7################################# [ 50%]
Re-declaration of type docker_t
Failed to create node
Bad type declaration at /etc/selinux/targeted/tmp/modules/400/docker/cil:1
/usr/sbin/semodule: Failed!
2:docker-engine-1.9.1-1.el7.centos ################################# [100%]
[root@docker docker]# systemctl enable docker.service Set the system to automatically start the service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@docker docker]# service docker start start service
Redirecting to /bin/systemctl start docker.service
[root@docker ~]# docker ps #View the docker-driven process, there is currently no driver process
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]# docker images #View the docker image file, there is no image in the initial installation
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
2. Configure the server proxy to access the Internet: Since the Internet environment is to access the Internet through a proxy, this test machine needs to be configured with a proxy before it can access the Internet.
The configuration method is as follows: Edit /etc/profile and add the following
http_proxy=192.168.1.100:8005 #Set your own proxy server according to the actual situation
https_proxy=$http_proxy
http_proxy_username=test #Set if the proxy needs to be authenticated by username and password, and can not be set if username and password are not required to be authenticated.
http_proxy_password=12356
no_proxy=192.*.*.*,*.local,localhost,127.0.0.1 #Set the ip without proxy
[root@docker ~]# ping baidu.com #Test ping Baidu, the connection is successful, the configuration of the external network proxy is successful.
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=51 time=30.7 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=51 time=33.4 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=51 time=34.0 ms
I thought that through the above settings, the docker image file could be downloaded through docker pull [images name] , but the following error was reported:
[root@docker ~]# docker pull daocloud.io/library/node:8.1.0-slim #Through the pull command, the prompt will report an error, but I didn't understand it anyway, so I searched online.
After looking for a lot of methods, I finally found the reason, because docker needs to configure the proxy to access the Internet separately.
Error response from daemon: invalid registry endpoint https://daocloud.io/v0/: unable to ping registry endpoint https://daocloud.io/v0/
v2 ping attempt failed with error: Get https://daocloud.io/v2/: remote error: handshake failure
v1 ping attempt failed with error: Get https://daocloud.io/v1/_ping: remote error: handshake failure. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry daocloud.io` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/daocloud.io/ca.crt
3. Configure the docker proxy to access the Internet and add the following configuration files
[root@docker ~]# vim /etc/systemd/system/docker.service.d/http-proxy.conf #Add a proxy configuration file, the content is as follows:
[Service]
Environment="HTTP_PROXY=10.109.134.247:8005"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
Save and exit, use the pull command again to download successfully, you can use the pull command to download the mirror, and finally get it.
[root@docker ~]# systemctl daemon-reload #Reload daemon
[root@docker ~]# systemctl show docker --property Environment #Check whether the set proxy environment is successful.
Environment=HTTP_PROXY=192.168.1.100:8005 NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com
[root@docker ~]# systemctl restart docker #Or direct service docker restart to restart the docker service.
Starting docker (via systemctl): [ OK ]
[root@docker ~]# docker images #View the docker image file, there is no image in the initial installation
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
[root@docker ~]# docker pull busybox #Download the busybox image to the local image repository through pull.
latest: Pulling from busybox
f9ea5e501ad7: Pull complete
ac3f08b78d4e: Pull complete
Digest: sha256:da268b65d710e5ca91271f161d0ff078dc63930bbd6baac88d21b20d23b427ec
Status: Downloaded newer image for busybox:latest #Download busybox image successfully
[root@docker docker]# docker pull daocloud.io/library/nginx:latest #Download nginx image successfully
latest: Pulling from daocloud.io/library/nginx
2cd56ba950c8: Pull complete
8ecf8a9b915f: Pull complete
2f035d3cb1ca: Pull complete
33ff728209b6: Pull complete
a8788126754a: Pull complete
534bc4991cb2: Pull complete
4eff2ba6990a: Pull complete
ca14437b52c6: Pull complete
64d6b4f35a10: Pull complete
476b0368435b: Pull complete
Digest: sha256:cb29ee85b234f356fb8a77d8cfb78b42355f7f016f528f11a2a5f75e4862dc94
Status: Downloaded newer image for daocloud.io/library/nginx:latest
[root@docker docker]# docker images #Check the local image repository again, there are already 2 images just downloaded.
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
daocloud.io/library/nginx latest 476b0368435b 7 days ago 108.9 MB
busybox latest ac3f08b78d4e 12 days ago 1.146 MB
By the way, provide the domestic mirror address:
https://hub.daocloud.io/repos?type=featured