docke - docker introduction and installation

Keywords: Linux Operation & Maintenance Docker

1, Docker introduction

1. Introduction

Docker is an open source application container engine and a lightweight container technology. Open source based on Go language and Apache 2.0 protocol. Docker allows developers to package their applications and dependency packages into a lightweight and portable container, and then publish them to any popular Linux machine. It can also realize virtualization. The container completely uses the sandbox mechanism, and there will be no interface between them. More importantly, the performance overhead of the container is very low.

Docker's concept: Build, Ship and Run Any App,Anywhere, that is, through the management of the life cycle of application component encapsulation, distribution, deployment and operation, the user's app (which can be a WEB application or database application) and its running environment can be encapsulated at one time and run everywhere.

A complete Docker consists of the following parts:

  • DockerClient client
  • Docker Daemon
  • Docker Image mirroring
  • DockerContainer container

2. Docker architecture

Docker architecture

Docker uses client server (C/S) architecture mode and remote API s to manage and create docker containers. Docker containers are created through docker images. The relationship between container and image is similar to that between object and class in object-oriented programming.

Docker adopts C/S architecture. Docker daemon is used as the server to accept requests from customers and process these requests (create, run and distribute containers). The client and server can either run on the same machine or communicate through socket or RESTful API.

Docker daemon generally runs in the background of the host, waiting to receive messages from the client. Docker client provides users with a series of executable commands. Users can use these commands to interact with docker daemon.

3. Comparison between virtual machine and docker container

2, Installation of Docker

Official website:
https://docs.docker.com/
Alibaba cloud open source mirror station:
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/
stable/Packages/

1. Package installation

Download 172 in real machine.25.254.250 20 in the host/catalogue
 Use the network warehouse in the virtual machine to point to 20 in the real machine/Directory location for software installation
cd /etc/yum.repos.d
vim docker.repo
---
[docker]
name=docker-ce
baseurl=http://172.25.76.250/20
gpgcheck=0
---
yum repolist

Copy 76.250 20 in/And install the software in the directory
lftp 172.25.76.250
>cd /root/
>mirrio 20/

install
install -y
    docker-ce-20.10.8-3.el7.x86_64.rpm
    container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
    containerd.io-1.4.9-3.1.el7.x86_64.rpm
    docker-ce-cli-20.10.8-3.el7.x86_64.rpm
    docker-ce-rootless-extras-20.10.8-3.el7.x86_64.rpm
    docker-scan-plugin-0.8.0-3.el7.x86_64.rpm
    fuse3-libs-3.6.1-4.el7.x86_64.rpm
    fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
    slirp4netns-0.4.3-4.el7_8.x86_64.rpm

2. Start service

Set startup and self startup
systemctl enable --now docker
 see docker information
docker info
 Warning found
---
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
---


View parameter content
sysctl -a | grep bridge-nf-call-iptables
 Edit file
vim /etc/sysctl.d/docker.conf
---
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
---
Refresh the kernel because the kernel settings have been changed
sysctl --system	
View again docker information
docker info


3. Testing

Find container
docker search yakexi007
 Download the game in the pull container(The resource must be pulled from it, or it cannot be used even if it is put into a container)
docker pull yakexi007/game2048
 View running containers
docker ps
 Start container
docker run -d --name demo0 -p 80:80 yakexi007/game2048
 Enter the name of the virtual machine in the browser ip You can see the contents pulled from the container. 2048 is a little fun. Similarly, Mario will not repeat it


4. docker instruction

The specific meaning can be - help. Learning to use help is a step to become a big man. In addition, it can be translated according to English. It will be used later naturally ~

start-up docker: 
systemctl start docker
systemctl enable --now  docker
 Import mirror:
docker load -i game2048
 Run container:
docker run -d --name game1 -p 80:80 game2048
docker tab Key completion to view commands

View mirror

Load mirror ubuntu

Run container
-it A virtual temporary interactive interface appears
--name Name of the container
-p	Container port, real port: virtual port

Posted by tvaughan77 on Sat, 09 Oct 2021 06:23:30 -0700