Skip to content

Instantly share code, notes, and snippets.

@ppatierno
Created December 2, 2016 13:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ppatierno/36467ffdeff3ce746068ab0b39a96aac to your computer and use it in GitHub Desktop.
Save ppatierno/36467ffdeff3ce746068ab0b39a96aac to your computer and use it in GitHub Desktop.
How to specify --insecure-registry needed for OpenShift "cluster up"
It could happen that with your Docker installation you don't have the following configuration file :
/etc/sysconfig/docker
Without it, the Docker daemon started as a service (i.e. with systemd so using "sudo systemctl start docker" or
"sudo systemctl enable docker" to start at OS startup) gets the configuration from following file :
/usr/lib/systemd/system/docker.service
You can ovveride this configuration in the following way :
1. create /etc/systemd/system/docker.service.d directory
2. create /etc/systemd/system/docker.service.d/docker.conf file
Now docker.conf becomes the configuration file used by Docker daemon on startup. You can start just copying the same configuration
from the default file but it's important to add the following line :
ExecStart=
before your real ExecStart. It's needed to clear the predefined ExecStart in the default file in order to use the new one.
Without this line, you could have following error on starting Docker :
docker.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.
So, for example, in order to add --insecure-registry command line options to the Docker daemon start, you could have :
ExecStart=
ExecStart=/usr/bin/dockerd --insecure-registry 172.30.0.0/16
After changing the configuration with a custom docker.conf file, you need to flush changes :
sudo systemctl daemon-reload
and then restart Docker :
sudo systemctl restart docker
Of course, the other way is not having Docker daemon running as a service but starting it directly from command line with :
sudo dockerd --insecure-registry 172.30.0.0/16
@cg-cnu
Copy link

cg-cnu commented Aug 30, 2018

Or you can simply add the ip address in the
/etc/docker/daemon.json file as below...

{
  "insecure-registries" : ["172.30.0.0/16"]
}

@An0n-V
Copy link

An0n-V commented Jun 20, 2021

Thank you it really works fine guys, cg-cnu that way is very quick and simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment