linux Enterprise Operation and maintenance - Docker container

1, Docker container introduction

1. Docker is an open source application container engine, which allows developers to package their applications and dependency packages into a portable image, and then publish them to any popular Linux or Windows machine, or realize virtualization. Containers are completely sandboxed, and there will be no interface between them
2. Solomon Hykes, the father of docker, said: docker is like a traditional freight container. Docker is an engine for managing containers, packaging and deploying platforms for applications, rather than a simple virtualization technology. The container does not need to encapsulate the virtual machine in advance, but shares the host, which can be understood as a process on the host.
3. The whole life cycle of docker consists of three parts: image + container + repository. Containers are instantiated from images. It can also be said that images are files and containers are processes. The container is created based on the image, that is, the processes in the container depend on the files in the image. The files here include executable files, dependent software, library files, configuration files, etc. required for process operation

1. Comparison between traditional virtualization technology and Docker container technology

2. How the container works

3. Docker installation

Put the docker Ce (community version) installation package required by the virtual machine into the Apache release directory on the real machine
server1 configures docker software warehouse and installs docker CE


yum -y install docker-ce

Start the service and start it automatically;

docker info: displays the docker system information, including the number of images and containers. Normal startup is as follows:

docker info: displays docker system information, including the number of images and containers
If two network errors occur

The solution is as follows: Edit/etc/sysctl.d Under directory docker.conf File, write two statements;
The system will start from/usr/lib/sysctl.d/.conf and /etc/sysctl.d/.conf Load application system configuration;
Manually load all configuration files and execute: sysctl --system

[root@server1 sysctl.d]# cd /etc/sysctl.d
[root@server1 sysctl.d]# vim  docker.conf 
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
[root@server1 sysctl.d]# sysctl  --system   

3. Test

Pull the game in the warehouse

[root@server1 ~]# docker images	##View mirror
yakexi007/mario   latest    9a35a9e43e8c   6 years ago   198MB
[root@server1 ~]# docker run -d --name demo -p 8080:8080 yakexi007/mario ##Create with mirror
[root@server1 ~]# docker ps 
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS         PORTS                                       NAMES
81cdbbc2c30f   yakexi007/mario   "python3 -m http.ser..."   10 seconds ago   Up 9 seconds>8080/tcp, :::8080->8080/tcp   demo

Enter in the browser to have a good time

2, Commands in 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
attach     diff       info       node       rm         stats      version
build      events     inspect    pause      rmi        stop       volume
builder    exec       kill       plugin     run        swarm      wait
commit     export     load       port       save       system     
config     help       login      ps         search     tag        
container  history    logout     pull       secret     top        
context    image      logs       push       service    trust      
cp         images     manifest   rename     stack      unpause    
create     import     network    restart    start      update 
docker images	docker Mirror view
docker ps View started mirror services
docker ps -a	View all mirror services

Tags: Linux Operation & Maintenance Docker

Posted on Sun, 10 Oct 2021 23:39:46 -0400 by Buglish