Docker CentOS7 system installation deployment and basic tutorials

  • 2020-05-15 03:13:50
  • OfStack

Description:

This article describes how to install and deploy the Docker environment on an CentOS7 system. This article refers to the official Docker documentation as follows:

https://docs.docker.com/engine/installation/centos/

Install and deploy the Docker environment on the CentOS7 system

1 CentOS7 installation (omitted)

2 upgrade system

yum update

You need to restart the system after the upgrade is completed.

Add the docker yum source

Execute the following command:


cat >/etc/yum.repos.d/docker.repo
name=Docker
Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

Install the Docker package

yum install docker-engine

5 start the Docker service

service docker start

6 test run hello-world image

docker run hello-world

7 view docker information

Use the docker info command to refer to the system, Docker details:


docker info
Containers: 3
Images: 2
Server Version: 1.9.0
Storage Driver: devicemapper
Pool Name: docker-253:0-202597120-pool
Pool Blocksize: 65.54 kB
Base Device Size: 107.4 GB
Backing Filesystem: xfs
Data file: /dev/loop2
Metadata file: /dev/loop3
Data Space Used: 1.824 GB
Data Space Total: 107.4 GB
Data Space Available: 47.87 GB
Metadata Space Used: 1.655 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.146 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.20.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 24
Total Memory: 11.57 GiB
Name: localhost.localdomain
ID: VIAJ:MW46:FVFJ:QN7G:XI66:OUBO:M65B:KAUE:BIPC:LL5D:HBCL:762N

Create the docker user group and place the users inside the docker group

It is recommended to use a non-root user to run docker, as root users running docker images are very insecure.

Create test1 users and add them to the docker user group:

[[email protected]~]# useradd test1
[[email protected]~]# usermod -aG docker test1

Cut to test1 user and run docker image:

[[email protected]~]# su test1
[[email protected]]$
[[email protected]]$ docker run hello-world

9. Set dock service to boot

chkconfig docker on

10 unload Docker

yum list installed | grep docker
yum -y remove docker-engine.x86_64
rm -rf /var/lib/docker

The relevant user is then deleted.

Supplementary notes:

About Docker's network

Similar to kvm, it appears to be the way to use Bridges:


[[email protected] ~]# ifconfig
docker0: flags=4163 mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:84ff:fe7f:4510 prefixlen 64 scopeid 0x20
ether 02:42:84:7f:45:10 txqueuelen 0 (Ethernet)
RX packets 12 bytes 840 (840.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 258 (258.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 20530318 bytes 1812359321 (1.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20530318 bytes 1812359321 (1.6 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth9422d62: flags=4163 mtu 1500
inet6 fe80::6c36:d0ff:fef5:3996 prefixlen 64 scopeid 0x20
ether 6e:36:d0:f5:39:96 txqueuelen 0 (Ethernet)
RX packets 8 bytes 648 (648.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10 bytes 828 (828.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.0242847f4510 no veth9422d62
[[email protected] ~]#

Thank you for reading, I hope to help you, thank you for the support of this site!


Related articles: