docker 高级配置

Last updated on November 20, 2024 am

🧙 Questions

安装最新的docker

☄️ Ideas

修改配置文件 (可选)
sudo systemctl stop docker
sudo vim /etc/docker/daemon.json

# ===================== daemon.json ==========================
{
	"max-concurrent-downloads": 3,
	"max-concurrent-uploads": 5,
	"graph": "${customLocalPath}",
 	"insecure-registries": ["${customPrivateRepository}"],
    "registry-mirrors": ["https://3fe1zqfu.mirror.aliyuncs.com"],
    "storage-driver": "overlay2",
	"storage-opts": ["overlay2.override_kernel_check=true"],
	"log-driver": "json-file",
	"log-opts": {
		"max-size": "100m",
		"max-file": "3"
	}
}
# ===================== daemon.json ==========================

sudo systemctl restart docker
sudo systemctl status docker
配置阿里加速镜像仓库
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://3fe1zqfu.mirror.aliyuncs.com"],
  "data-root":"/data/docker"
}
EOF
sudo cat /etc/docker/daemon.json
sudo systemctl daemon-reload
sudo systemctl restart docker
Docker版本降级(可选)
sudo systemctl stop docker
# 19.03.13-3.el7
# sudo yum downgrade --setopt=obsoletes=0 -y docker-ce-19.03.13-3.el7 docker-ce-cli-19.03.13-3.el7 containerd.io
sudo yum downgrade --setopt=obsoletes=0 -y docker-ce-${version} docker-ce-cli-${version} containerd.io
sudo systemctl start docker
sudo systemctl status docker
添加用户到docker用户组

sudo gpasswd -a ${user} docker

sudo gpasswd -a ispong docker 
newgrp docker
sudo chmod a+rw /var/run/docker.sock
查看docker版本号
docker version --format '{{.Server.Version}}'
代理
# 查看
systemctl show --property=Environment docker

vim /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://172.16.215.83:7890"
Environment="HTTPS_PROXY=http://172.16.215.83:7890"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

sudo systemctl daemon-reload
sudo systemctl restart docker

docker 高级配置
https://ispong.isxcode.com/kubernetes/docker/docker 高级配置/
Author
ispong
Posted on
March 9, 2021
Licensed under