docker常用服务配置 daemon.json
[toc]
日志大小以及数量配置,防止无限打日志导致磁盘满
/var/lib/docker/containers 默认容器日志路径
vi /etc/docker/daemon.json
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"}
配置镜像源:
"registry-mirrors": ["https://0g612ngr.mirror.aliyuncs.com/"]
工作目录
"graph":"/data/docker"
存储驱动
"storage-driver":"overlay2"
自定义docker网络地址
"bip":"172.7.5.1/24",
所有配置文件修改后,需要重启docker服务方能生效
针对国内墙了docker.io的问题:
dockerd 配置 针对pull push > https://docs.docker.com/config/daemon/systemd/#httphttps-proxy
docker-cl 配置 针对build >https://docs.docker.com/network/proxy/#configure-the-docker-client
"proxies": {
"http-proxy": "http://ubuntu.zhenghao.org:7890",
"https-proxy": "http://ubuntu.zhenghao.org:7890",
"no-proxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
#!/bin/bash
src_image=$1
docker pull ${src_image}
image=`echo ${src_image}|awk -F / '{print $NF}'`
dest_image=registry.cn-shenzhen.aliyuncs.com/xxxxx/${image}
docker tag ${src_image} ${dest_image}
docker login --username=xxxxx --password=xxxxx registry.cn-shenzhen.aliyuncs.com
docker push ${dest_image}
echo -e "\ndocker pull ${dest_image}"
配置示例
{
"graph":"/data/docker", //工作目录
"storage-driver":"overlay2", //存储驱动
insecure-registries
"insecure-registries":["registry.access.redhat.com","quay.io"], //私有仓库
"registry-mirrors":["https://q2gr04ke.mirror.aliyuncs.com"],//镜像源
"bip":"172.7.5.1/24",//docker网络地址 中间两段对应宿主机后两段
"exec-opts":["native.cgroupdriver=systemd"],//启动参数,指定cgroup驱动
"live-restore":true//docker引擎挂掉后,不影响已经启动的容器,启动后不依赖dokcer引擎
}
还不快抢沙发