Docker配置文件
一、配置文件的位置
# Linux 和 macOS
cat /etc/docker/daemon.json
# Windows
notepad C:\ProgramData\Docker\config\daemon.json
默认是一个空白文件。如果没有这个文件,自行创建即可。
二、示例配置
你能够通过配置文件,修改许多内容,比如:
daemon.json
{
"registry-mirrors": ["https://your-mirror-address"],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2",
"data-root": "/var/lib/docker",
"dns": ["8.8.8.8", "8.8.4.4"],
"insecure-registries": ["myregistry.local:5000"],
"experimental": true,
"metrics-addr": "0.0.0.0:9323",
"default-runtime": "runc",
"runtimes": {
"runc": {
"path": "runc"
},
"custom-runtime": {
"path": "/usr/local/bin/custom-runtime"
}
}
}
三、配置项
3.1 镜像源
国内网络可能无法拉取 Docker 镜像,可以配置加速地址解决:
daemon.json
{
"registry-mirrors": [
"https://docker.1panel.live"
]
}
在 github 获取镜像地址,自行分辨是否可信。
https://github.com/dongyubin/DockerHub
3.2 指定日志驱动
{
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
}
}