0

I have a docker 18.03.1-ce running on CentOS 7. I am trying to add another insecure registry to it.

docker info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.639GiB
Name: ecs-cicd-0634.novalocal
ID: RGQ5:HMFO:NV2S:VXZG:U3RO:NKQ2:2BMT:XGMX:O6L7:SSWU:TCXV:5BVT
Docker Root Dir: /data/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 registry.titan.languoguang.com:5000
 127.0.0.0/8
Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

I just want to add another insecure registry to Docker, something like

registry-cbu.languoguang.com

Because my docker environment is a random docker environment, so i can't ssh The docker environment to modify the /etc/docker/daemon.json file when i use it in CI pipeline. Add Insecure Registry to Docker

How to add my own insecure registry to Docker using shell script, thanks.

Languoguang
  • 2,166
  • 2
  • 10
  • 15

1 Answers1

0

use jp merge two json files, it works for me.

  # install jp
  yum install epel-release -y
  yum install jq -y
  jq --version

  # add registry-cbu.languoguang.com
  cat /etc/docker/daemon.json
  jq -s '.[0]."insecure-registries"=([.[]."insecure-registries"]|flatten)|.[0]' /etc/docker/daemon.json $PWD/ci/daemon.json > /etc/docker/daemon.extension.json
  mv -f /etc/docker/daemon.extension.json /etc/docker/daemon.json
  cat /etc/docker/daemon.json

  echo "restart docker..."
  sudo systemctl daemon-reload
  sudo systemctl restart docker
Languoguang
  • 2,166
  • 2
  • 10
  • 15