Docker docker environment construction & docker compose environment construction

Time:2021-12-3

1、 Docker environment construction

1. Docker installation

#Update Yum source
yum update -y
#Install docker
yum list installed | grep docker
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce-18.09.6-3.el7 docker-ce-cli-18.09.6-3.el7 containerd.io-1.2.0-3.el7
systemctl start docker
Systemctl enable docker. // startup starts automatically

2. Docker upgrade
Docker upgrade image download address

#Download docker-ce-xxx
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.09.6-3.el7.x86_64.rpm
#Upgrade docker CE
yum -y upgrade ./docker-ce-18.09.6-3.el7.x86_64.rpm
#Install docker CE
yum install ./docker-ce-18.09.6-3.el7.x86_64.rpm

3. Docker removal

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

2、 Construction of docker compose environment

1. Install docker compose

curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
##An error may be reported. Curl: (35) peer reports incompatible or unsupported protocol version. Execute Yum update - y NSS curl libcurl
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

2. Docker compose startup

#Start application
docker-compose up -d
#Check
docker-compose ps
#Add application
docker-compose create
#Check日志
docker-compse logs -f <server-name>

3、 Docker container management

1. Create and push images

#Commit mirror to local according to container
docker commit -m "add image" -a 'tt' 37bb image-name
#Click tag according to the generated image
docker tag image-name 111.01.1.6/public/image-name:base1.0
#If the image warehouse needs to log in, log in
docker login 111.01.1.6 
#Push image
docker push 111.01.1.6/public/image-name:base1.0

2. About configuring the image warehouse

#Error response from daemon: get https://192.168.208.40:10050/v1/ \_ ping: http: server gave HTTP response to HTTPS client
#1. View the imported image warehouse address
cat /etc/docker/daemon.json
#1. Add image warehouse address
echo '{ "insecure-registries":["111.01.1.6","111.01.1.2"] }' > /etc/docker/daemon.json
#2. Restart docker
systemctl restart docker

3. About docker network

#Bridge network created by default when network driver is not specified
docker network create default_network
#View network internal information
docker network inspect default_network
#List all lists of networks
docker network  ls
#Remove the specified network
docker network rm default_network

4、 Docker common commands

Recommended Today

Win10 system comes with screenshot tool

How to use the screenshot function of win10 system The screenshot function is often used in the process of daily computer use. In fact, win10 system itself has the screenshot function. The following describes how to use the screenshot function of win10 system. Tools / raw materials  Computer system: Windows 10 professional edition Method / […]