docker访问私有harbor仓库配置

1、docker添加私有仓库

# 添加 私有仓库,请将IP改写为你的私有仓库地址
# 若没有 /etc/docker 则创建, 若存在 daemon.json 则备份
mkdir -p /etc/docker && cp /etc/docker/daemon.json /etc/docker/daemon.json-bk

cat  > /etc/docker/daemon.json << EOF

{
  "insecure-registries": [
    "192.168.51.133:80"
  ]
}

EOF

# 重启docker 或者 reload下docker配置
systemctl reload docker

# systemctl restart docker

  2、docker镜像加速


mkdir -p /etc/docker && cp /etc/docker/daemon.json /etc/docker/daemon.json-bk

cat > /etc/docker/daemon.json <<-EOF

{
  "registry-mirrors": ["https://registry.docker-cn.com","https://registry.cn-hangzhou.aliyuncs.com"]
}

EOF

systemctl reload docker

3、修改docker默认数据目录

# 修改 data-root 的值为你的 docker 实际数据目录

mkdir -p /etc/docker && cp /etc/docker/daemon.json /etc/docker/daemon.json-bk

cat  > /etc/docker/daemon.json << EOF

{
  "data-root": "/data/bcs/lib/docker"

}

EOF

# systemctl restart docker

4、完整的docker常用配置

# 若不想改变docker默认数据目录,请删除 data-root 一行;
# 或者将 data-root 的值改成 "/var/lib/docker"

mkdir -p /etc/docker && cp /etc/docker/daemon.json /etc/docker/daemon.json-bk

cat  > /etc/docker/daemon.json << EOF

{
  "data-root": "/data/bcs/lib/docker",
  "exec-opts": [
    "native.cgroupdriver=systemd"
  ],
  "registry-mirrors": [
    "https://mirror.ccs.tencentyun.com",
    "https://registry.cn-hangzhou.aliyuncs.com"
  ],
  "max-concurrent-downloads": 10,
  "live-restore": false,
  "log-level": "info",
  "log-opts": {
    "max-size": "100m",
    "max-file": "5"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "insecure-registries": [
    "192.168.51.133",
     "yourhub.com"
  ]
}

EOF

# systemctl restart docker

你可能感兴趣的:(docker,云原生,docker,容器,运维)