Where should I set the '--insecure-registry' flag on Mac OS?
Asked Answered
K

7

46

I am using OS X 10.10. When trying to communicate with our team's private docker registry, it keeps giving me errors like this:

Error: Invalid registry endpoint https://registry.xxx.xxx/v1/: Get
https://registry.af-sys.com/v1/_ping: dial tcp xx.xxx.xxx.xxx:xxx: i/o timeout.
If this private registry supports only HTTP or HTTPS with an unknown CA
certificate, please add --insecure-registry...

On Ubuntu system this error can be resolved by adding DOCKER_OPTS into the /etc/default/docker configuration file like this:

DOCKER_OPTS="$DOCKER_OPTS --insecure-registry myregistry:5000"

Does Mac OS have a similar configuration file where I can add the DOCKER_OPTS option?

Kelikeligot answered 27/9, 2015 at 13:5 Comment(0)
P
22

You have to set it to Docker Machine's / Boot2Docker profile file: docker-machine ssh <machine name>

/var/lib/boot2docker/profile

EXTRA_ARGS='
--label provider=virtualbox --insecure-registry myregistry:5000

'

And then restart Docker service.

sudo /etc/init.d/docker restart
Pansie answered 27/9, 2015 at 16:57 Comment(2)
could not find /var/lib/boot2docker/profile and /etc/init.d/docker on docker version Docker version 17.03.1-ce, build c6d412eOakley
you need to ssh to the docker machineMccants
E
130

I was looking for a way to set --insecure-registry in Docker for Mac. Turned out to be simpler than what I first thought...

In the Docker Desktop application :

  1. click on the Settings icon
  2. select Docker Engine menu entry
  3. add your insecure registries

how to set docker --insecure-registry on mac os x

Don't forget to Apply & Restart and you're ready to go.

Electrodynamic answered 14/9, 2016 at 13:57 Comment(8)
Tip, if your using vpn connection to access some "insecure registry" on a remote server, it seems you sometimes have to restart docker client after establishing vpn connection.Grishilda
This is the absolute correct and best answer - why SO wouldn't move it up top is beyond me.. thanks!Molly
What would be the correct setting for using localhost as registry here? I've tried to enter localhost:5000 as insecure registry but when I curl localhost:5000/v2/ the connection gets refused...Betake
Did you try with 127.0.0.1 instead of localhost? or maybe you should use the docker-machine IP, which you can get with docker-machine ip defaultElectrodynamic
How would you add these kinds of options: DOCKER_OPTS = "--bip=xx.xx.xx.x/xx --dns xx.xx.x.xx --dns xx.xx.x.xx --dns-search xx.xx.xx" on the macOS version of dockerTarragona
You can "Configure the Docker daemon by typing a json docker daemon configuration file" in the Advanced tab. Does it help?Electrodynamic
I already knew that fact, it was more specifically how to add these options in the config, but I have found my answer, dns-search and dns both accepts an array...Tarragona
This UI is outdatedPembroke
P
22

You have to set it to Docker Machine's / Boot2Docker profile file: docker-machine ssh <machine name>

/var/lib/boot2docker/profile

EXTRA_ARGS='
--label provider=virtualbox --insecure-registry myregistry:5000

'

And then restart Docker service.

sudo /etc/init.d/docker restart
Pansie answered 27/9, 2015 at 16:57 Comment(2)
could not find /var/lib/boot2docker/profile and /etc/init.d/docker on docker version Docker version 17.03.1-ce, build c6d412eOakley
you need to ssh to the docker machineMccants
D
7

Working MacOS Big Sur

This is accessed throught he docker icon -> preferences enter image description here

Derisive answered 23/11, 2020 at 3:16 Comment(0)
E
6

The proper way to set it is via the --engine-insecure-registry argument to docker-machine:

docker-machine create --driver virtualbox \
  --engine-insecure-registry myregistry:5000 dev

You can also pass other options using --engine-opts. For example, set dns via --engine-opt dns=8.8.8.8

This essentially ends up setting EXTRA_ARGS in /var/lib/boot2docker/profile

Estrous answered 25/11, 2015 at 7:22 Comment(1)
there are no more boot2docker in new docker version :(Kurland
C
5

Mac docker's config file was in ~/.docker/daemon, The configuration you added to the software interface is the wrong configuration for the MAC,because it's an extra "," like this.

    {
    "insecure-registries" : [
        "XXXX:5000", \\ <-- THIS ","
      ],
      "registry-mirrors" : [
        "https://registry.docker-cn.com", \\ <--  THIS ","
      ]
    }

The right config is

    "insecure-registries" : [
        "XXXX:5000"  \\ there is no comma, it is working.
      ],
      "registry-mirrors" : [
        "https://registry.docker-cn.com" \\ there is no comma, it is working.
      ]
    }
Cotterell answered 13/2, 2019 at 8:30 Comment(1)
For version 2.3.0.5, the file is ~/.docker/.daemon.json. Did you forgot to type the appendix or it was different for earlier versions?Riverhead
L
5

For docker desktop 2.3.x in MAC , it can be set as follows: Go to "docker" -> "preferences" -> "Docker Engine" and add the following:

"insecure-registries": [
        "localhost:8082",
        "10.23.454.34:2323",
      ]
Landsturm answered 19/8, 2020 at 14:56 Comment(2)
Welcome to StackOverflow! Please, provide an explanation in order to make the given code more understandableMeneau
technically not a URL, a host:port (no scheme)Pinion
M
2

As of Docker 2.3.0.3, it must be in host:port format, i.e you have to remove http/https. Sample configuration

"insecure-registries": [
    "registry.com:443",
    "registry-2.net:80"
  ]
Matelda answered 1/6, 2020 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.