CentOS 修改docker库为本地库

1) 修改/etc/docker/daemon.json文件:

root@d5-006:~# cat /etc/docker/daemon.json
{
"insecure-registries" : [ "https://*****:8080","https://*:8444"],
"registry-mirrors":  [ "https://****.com:8443","https://***.com:8444"],
"disable-legacy-registry": true
}

  1. 修改启动文件:/usr/lib/systemd/system/docker.service, 添加$INSECURE_REGISTRY 到启动命令行:
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target rhel-push-plugin.socket registries.service
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          --seccomp-profile=/etc/docker/seccomp.json \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
          $REGISTRIES
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
KillMode=process

[Install]
WantedBy=multi-user.target

3)修改/etc/sysconfig/docker文件,添加$ADD_REGISTRY变量:

ADD_REGISTRY="--add-registry ***.com:8442 --add-registry m5-nexus01.****.com:8444"
  • 参考文章:

http://www.informit.com/articles/article.aspx?p=2464012&seqNum=3

你可能感兴趣的:(CentOS 修改docker库为本地库)