44

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mainframer
  • 20,411
  • 12
  • 49
  • 68

7 Answers7

128

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.

Community
  • 1
  • 1
  • 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. – Timo Dec 28 '16 at 09:46
  • 2
    This is the absolute correct and best answer - why SO wouldn't move it up top is beyond me.. thanks! – Marco Massenzio Mar 16 '17 at 03:33
  • 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... – ofhouse Mar 28 '17 at 16:07
  • 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 default` – Pierre-Alexis de Solminihac Mar 29 '17 at 14:19
  • 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 docker – AKFourSeven Jun 21 '17 at 10:58
  • 1
    You can *"Configure the Docker daemon by typing a json docker daemon configuration file"* in the **Advanced** tab. Does it help? – Pierre-Alexis de Solminihac Jun 23 '17 at 14:05
  • 1
    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... – AKFourSeven Jun 26 '17 at 08:13
  • This UI is outdated – Daniel Patrick Mar 11 '21 at 13:49
23

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
typingduck
  • 825
  • 10
  • 15
Lauri
  • 4,336
  • 3
  • 18
  • 18
7

Working MacOS Big Sur

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

Luis Liz
  • 1,939
  • 4
  • 20
  • 31
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

manojlds
  • 290,304
  • 63
  • 469
  • 417
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",
      ]
Anjum....
  • 4,086
  • 1
  • 35
  • 45
AMIT DATTA
  • 51
  • 1
  • 1
4

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.
      ]
    }
刘嘿嘿
  • 51
  • 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? – Chong Sep 24 '20 at 10:44
1

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"
  ]
0x8091
  • 11
  • 1