Table of contents
1.1 Three concepts of Docker virtualization
1. Docker virtualization
1.1 Three concepts of Docker virtualization
Mirroring: Docker’s mirroring is actually a template, similar to our common IOS mirroring, it is a template
Container: A common application or system that uses mirroring, we call it a container
Warehouse: Warehouse is a place to store images, which are divided into public warehouses (Public) and private warehouses (Private).
Physical machine -- the sea
Docker Engine -- Freighter
Docker container -- container
Application Services -- Cargo
1.2 Docker virtualization
Docker virtualization features: lightweight, high performance, security, stability, easy management, etc.
2. Docker deployment
This deployment uses yum installation and source code installation
2.1 Source installation
Based on the CentOS7.x Linux system, build a Docker virtualization platform from 0, using the binary Tar package method, the deployment method and instructions are as follows
Download the package from the Docker official website;
root@zfl ~]# wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz
Decompress it through the Tar tool; (-x extract decompression, -z gzip compression format, -v verbose detailed display, -f file file attributes)
[root@zfl ~]# ls
anaconda-ks.cfg docker-20.10.9.tgz
[root@zfl ~]# tar -xzvf docker-20.10.9.tgz
docker/
docker/containerd-shim-runc-v2
docker/dockerd
docker/docker-proxy
docker/ctr
docker/docker
docker/runc
docker/containerd-shim
docker/docker-init
docker/containerd
[root@zfl ~]#
Deploy the decompressed Docker program to the /usr/local/ directory;
[root@zfl ~]# \mv docker /usr/local/
Create Docker users and groups, and authorize Docker user and group access rights at the same time;
[root@zfl docker]# useradd -s /sbin/nologin docker -M
[root@zfl docker]# chown -R docker.docker /usr/local/docker/
Add the Docker program deployment directory to the PATH environment variable;
[root@zfl docker]# cat>>/etc/profile<<EOF
> export PATH=\$PATH:/usr/local/docker/
> EOF
[root@zfl docker]# source /etc/profile
#Start the Docker engine service;
[root@zfl docker]# nohup /usr/local/docker/dockerd &
[1] 11567
[root@zfl docker]# nohup: ignore input and append output to "nohup.out"[root@zfl docker]#
Check the Docker service process;
[root@zfl docker]# ps -ef|grep -aiE docker
root 11567 11497 0 20:57 pts/0 00:00:00 /usr/local/docker/dockerd
root 11575 11567 0 20:57 ? 00:00:00 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
root 11730 11497 0 20:57 pts/0 00:00:00 grep --color=auto -aiE docker
[root@zfl docker]#
View Docker version information;
[root@zfl docker]# docker version
Client:
Version: 20.10.9
API version: 1.41
Go version: go1.16.8
Git commit: c2ea9bc
Built: Mon Oct 4 16:03:22 2021
OS/Arch: linux/amd64
Context: default
Experimental: trueServer: Docker Engine - Community
Engine:
Version: 20.10.9
API version: 1.41 (minimum version 1.12)
Go version: go1.16.8
Git commit: 79ea9d3
Built: Mon Oct 4 16:07:30 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.4.11
GitCommit: 5b46e404f6b9f661a205e28d59c982d3634148f8
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@zfl docker]#
2.2 How to start Docker
background socket start
nohup /usr/local/docker/dockerd &
boot with port
nohup /usr/local/docker/dockerd -H 0.0.0.0:2375 & 但是 server看不了
因此需要带-H
docker -H 127.0.0.1 version
port socket start
nohup /usr/local/docker/dockerd -H 0.0.0.0:2375 -H unix:///var/run/docker.sock &
2.3 yum installation
Deploy dependencies
yum install -y yum-utils device-mapper-persistent-data lvm2
Add Docker repository, here use the domestic Aliyun yum source
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Install docker-ce, install the latest version directly here
yum install -y docker-ce
Modify the docker configuration file
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{ "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log- opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ], "registry-mirrors": ["https ://uyah70su.mirror.aliyuncs.com"] } EOF # Note, because the domestic image pull is slow, registry-mirrors is added at the end of the configuration file mkdir -p /etc/systemd/system/docker.service.d
Restart the docker service
systemctl daemon-reload
systemctl enable docker.service
systemctl start docker.service
Query the docker process
ps -ef|grep -aiE docker