:::info 视频演示 https://www.bilibili.com/video/BV1B3411q7Bs/ :::
Centos 7.8
在线
sudo yum install -y yum-utils device-mapper-persistent-data lvm2# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyuncurl -sSL https://get.daocloud.io/docker | shsystemctl enable dockersystemctl start docker# 国内下载curl -L https://get.daocloud.io/docker/compose/releases/download/v2.2.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose
离线
下载资源
sudo yum install -y --downloadonly --downloaddir=$PWD/devel yum-utils device-mapper-persistent-data lvm2sudo yum install -y devel/*.rpmyum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoyum install -y --downloadonly --downloaddir=$PWD/docker docker-cecurl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ./docker-compose
安装
sudo yum install -y devel/*.rpmsudo yum install -y docker/*.rpmsystemctl enable dockersystemctl start dockerchmod a+x ./docker-composecp ./docker-compose /usr/bin/
系统调优
echo off# 关闭selinux#setenforce 0sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config# 关闭防火墙systemctl stop firewalld.service && systemctl disable firewalld.service# 修改时区ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime# 系统语言sudo echo 'LANG="en_US.UTF-8"' >> /etc/profile;source /etc/profile# 关闭swapswapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab# 性能调优cat >> /etc/sysctl.conf<<EOFvm.swappiness = 0kernel.sysrq = 1net.ipv4.neigh.default.gc_stale_time = 120# see details in https://help.aliyun.com/knowledge_detail/39428.htmlnet.ipv4.conf.all.rp_filter = 0net.ipv4.conf.default.rp_filter = 0net.ipv4.conf.default.arp_announce = 2net.ipv4.conf.lo.arp_announce = 2net.ipv4.conf.all.arp_announce = 2# see details in https://help.aliyun.com/knowledge_detail/41334.htmlnet.ipv4.tcp_max_tw_buckets = 5000net.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_syn_backlog = 1024net.ipv4.tcp_synack_retries = 2net.ipv4.ip_forward=1EOFsysctl -p
Docker容器实例中解析DNS的顺序
- 查找Docker daemon内置的DNS服务器127.0.0.11
- 查找docker run创建容器实例时通过—dns参数设置的DNS服务器
- 查找Docker daemon通过—dns参数,或/etc/docker/daemon.json文件设置的DNS服务器
- 查找Docker宿主机上/etc/resolv.conf文件中配置的DNS服务器
- 查找Google的DNS服务器,如8.8.8.8和8.8.4.4,2001:4860:4860::8888和2001:4860:4860::8844
docker 加速
# /etc/docker/daemon.json"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
