After working for many years, I’ve encountered numerous users, and some content is not applicable
Installation can refer to the manual from Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
Install
Due to an unknown mysterious force, it is recommended to use cloud vendor-provided repository addresses for Docker installations within China; here, we recommend 阿里云
Set repository source address
yum install yum-utils device-mapper-persistent-data lvm2 && \
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Deploy the latest version
Docker, as a commonly used background service, is recommended to be set up for startup on boot. This command applies to CentOS 7.
sudo yum install -y docker-ce docker-ce-cli containerd.io && systemctl enable --now docker
Deploy specified version
Please provide the Chinese text you want me to translate. I am ready when you are.
yum list docker-ce --showduplicates | sort -r
sudo yum install -y docker-ce-18.09.2-3.el7 docker-ce-cli-18.09.2-3.el7 containerd.io-18.09.2-3.el7 && systemctl enable --now docker
Add Docker permissions for regular users
sudo usermod -aG docker ${USER}
Uninstall
sudo yum erase -y docker-ce docker-ce-cli containerd.io
Everyday use
Mirror Acceleration
There are still unknown mysterious forces causing slow image pulls. Domestic cloud providers have stepped up, offering many acceleration services; I still recommend them.
To obtain the accelerated access addresses, please register for an Alibaba Cloud account. This service is free, and Alibaba Cloud also provides a free image building service.
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.nju.edu.cn",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.mirrors.sjtug.sjtu.edu.cn"
]
}
EOF
systemctl daemon-reload && \
systemctl restart docker
Highly recommended control panel
docker volume create portainer_data && \
docker run -d --name=portainer --restart=always -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.20.3-alpine
Commonly Used Image Pulls
docker pull rancher/rancher:stable && docker pull portainer/portainer-ce:2.0.1 && \
docker pull centos:7 && docker pull ubuntu:20.04 && docker pull ubuntu:18.04 && \
docker pull redis:5 && docker pull redis:6 && \
docker pull alpine:3.11 && docker pull busybox:1.32 && \
docker pull rabbitmq:3.7-management && \
docker pull mariadb:10.2 && \
docker pull nginx:1.18 && docker pull nginx:1.19 && \
docker pull mysql:5.6 && docker pull mysql:8 && \
docker pull elasticsearch:6.8.11 && docker pull logstash:6.8.11 && docker pull kibana:6.8.11 && \
docker pull zookeeper:3.4 && \
docker pull influxdb:1.7 && docker pull grafana/grafana:7.3.1 && \
docker pull percona:8 && docker pull percona:5.6 && \
docker pull cloverzrg/frps-docker:0.34.3 && docker pull cloverzrg/frpc-docker:0.34.3
Common Command Combinations
https://docs.docker.com/engine/reference/commandline/docker/
Check container runtime status, add the __INLINE_CODE_0 parameter, view detailed container information; ignore image information at this time
docker ps --format "{{.Names}}: {{.Ports}}: {{.Size}}"
#portainer: 0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp: 0B (virtual 172MB)
#influxdb: 0.0.0.0:8086->8086/tcp: 183B (virtual 311MB)
Stop all containers
docker stop $(docker ps -a -q)
Delete all images
dokcer rmi $(docker images -a -q)
Export image
docker save <IMAGE NAME>:<IMAGE TAG> > -o XXX.tar
Export image and compress
docker save <IMAGE NAME>:<IMAGE TAG> | gzip > XXX.tar
Import image
docker load -i XXX.tar