Linux/Centos7.x安装Docker-CE及优化配置,使用国内镜像加速,安装更快
以Centos7为例,另一篇安装Docker-CE教程链接:https://4xx.me/archives/52.html
CentOS关闭selinux
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
关闭防火墙
systemctl stop firewalld.service && systemctl disable firewalld.service
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun --version 24.0
https://mirrors.tencent.com/help/docker-ce.html
# CentOS/RHEL
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
# 把软件仓库地址替换为:
sudo sed -i 's+download.docker.com+mirrors.cloud.tencent.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# 安装
sudo yum makecache fast
sudo yum install docker-ce
# 设置开机启动
sudo systemctl enable docker
# (start, stop, restart, try-restart, reload, force-reload, status)
systemctl start docker
通过修改daemon.json来改过Docker配置,daemon.json默认位于 /etc/docker/daemon.json
,如果没有可手动创建
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"insecure-registries": ["0.0.0.0/0"],
"registry-mirrors": ["https://mirror.ccs.tencentyun.com","http://f1361db2.m.daocloud.io"],
"storage-driver": "overlay2",
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
}
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
max-concurrent-downloads
下载线程数
max-concurrent-uploads
上传线程数
registry-mirrors
国内docker镜像仓库地址
vim /lib/systemd/system/docker.service
# 在[Service]下添加
Environment=HTTP_PROXY=http://proxyAddress:port
Environment=HTTPS_PROXY=http://proxyAddress:port
Environment=NO_PROXY=localhost,127.0.0.1
配置完成重载配置并重启docker