- 切换目录
cd /etc/docker
- 编辑daemon.json文件
vim daemon.json
{
"registry-mirrors": ["https://hh58wswg.mirror.aliyuncs.com"],
"log-driver":"json-file",
"log-opts": {"max-size":"100m", "max-file":"1"}
}
解释: registry-mirrors为配置镜像仓库地址,为一个数组,如果要配置多个,可以使用 ["https://hh58wswg.mirror.aliyuncs.com","https://xxx.mirror.aliyuncs.com"]
log-driver为docker容器镜像日志格式,这里一般采用json
log-opts 是log日志配置,max-size单个日志最大容量,max-file最多多少个日志文件
- 配置生效
systemctl daemon-reload
systemctl restart docker
注意:修改配置后仅对修改配置之后的容器才生效,配置容器日志大小是为了避免 no space left on device
评论区