moby: Docker daemon won't start if a registry-mirror is configured in /etc/docker/daemon.json

Description

I have a Nexus 3 docker mirror running in a local server, which my machine points to using /etc/docker/daemon.json. I’ve tested it a few times, got it working, all good.

However, I was using a ridiculously old version of docker and decided to update it in order to use multistage builds (the version I was using couldn’t handle the “AS” alias for stages), in fact, the newest I found(stable).

I completely removed docker, but left the daemon.json there, since I would need it anyway. Installed version 17.12.1 using a “.deb” and it immediately showed an error after the installation was done, showing that docker daemon was unable to start.

When trying to manually start it using dockerd, I got the following message:

invalid mirror: path, query, or fragment at end of the URI “http://192.168.1.201:8081/repository/docker-public/”

After about 30 minutes of searching, I’ve decided to try a different version, just to see what happens, and after downloading version 17.09.1, it started working again

Steps to reproduce the issue:

  1. Create /etc/docker/daemon.json and insert a registry-mirror, like the following:
{
        "registry-mirrors": ["http://192.168.1.201:8081/repository/docker-public/"]
}
  1. Update docker to version 17.12.1 using this link

Describe the results you received: Error when starting docker daemon

Describe the results you expected: Docker daemon should’ve started as usual

Additional information you deem important (e.g. issue happens only occasionally): Also happens with 17.12.0

Output of docker version:

Client:
 Version:	17.12.1-ce
 API version:	1.35
 Go version:	go1.9.4
 Git commit:	7390fc6
 Built:	Tue Feb 27 22:17:40 2018
 OS/Arch:	linux/amd64

Output of docker info:

Can't print, since daemon won't start.

Additional environment details (AWS, VirtualBox, physical, etc.): Using a regular ubuntu 16.04 installation behind a corporate firewall (usually a problem, but not this time I guess)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 47
  • Comments: 25 (2 by maintainers)

Commits related to this issue

Most upvoted comments

This is a hard problem for us (in my company) - Harbor mirror should be set to /hub project. Podman is very easy to configure to fix this, but Docker / Moby fails.

Can a Moby developer to react on this issue ?

I’ve found a solution ( cat <<EOF [Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// --registry-mirror http://$PULL_THROUGT_DN:$REPO_PORT --insecure-registry $PULL_THROUGT_DN:$REPO_PORT --insecure-registry=$SECURE_REGISTRY_DN --insecure-registry=$SECURE_REGISTRY_DN EOF ) | sudo tee /etc/systemd/system/docker.service.d/docker-options.conf and systemctl daemon-reload && systemctl restart docker worked with ubuntu

UPD Domain name without anu subpath

@FloMko does that work with a url where the mirror is at a sub path (https://mirror.example.com/docker/mirror)? Or just if it’s a domain name (https://mirror.example.com)?

Only FQDN without any subpath (comment has been updated)

Wild that we all have to set up elaborate reverse-proxy systems to get this to work for private registry mirrors. The last update here from a project maintainer seemed to indicate that this was a limitation years ago… but yet here we are in 2023 still going “I have to do what to make this work?”

Had a quick chat with some people on our slack, related to https://github.com/moby/moby/pull/38991#discussion_r271517220, because at the time, containerd did not have support for these.

Since then, containerd looks to have added support https://github.com/containerd/containerd/blob/adeba792f16bff6d8f68d560566ed50202634bac/remotes/docker/registry.go#L71, however, it has not yet been looked into if that can be used (and BuildKit would have to be updated to user/support it, as it currently doesn’t)

I’m seeing the same behavior with our Nexus docker group (private repo + proxy for public images).

Docker version:

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:20 2018
 OS/Arch:      linux/amd64

Our /etc/docker/daemon.json:

{
  "insecure-registries":[
    "192.168.1.10"
  ],
  "registry-mirrors": [
    "http://192.168.1.10/nexus/repository/docker-group"
  ]
}

FWIW, this only seems to be an issue with Docker. Gems, Apt, YUM, NPM, and Maven can all pull through Nexus just fine.

I’m observing similar behavior. Docker version:

docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:43 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:15:19 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

This config doesn’t work:

{
  "insecure-registries": ["insecure.server.example.com:4567"],
  "data-root": "/home/docker",
  "max-download-attempts": 65535,
  "registry-mirrors": ["https://artifactory.local.corp.net/artifactory"]
}

Docker daemon complains in logs: failed to start daemon: invalid mirror: path, query, or fragment at end of the URI "https://artifactory.local.corp.net/artifactory"

However, if I move registry-mirrors to separate pair of curly braces, it works

{
  "insecure-registries": ["insecure.server.example.com:4567"],
  "data-root": "/home/docker",
  "max-download-attempts": 65535
},
{
  "registry-mirrors": ["https://artifactory.local.corp.net/artifactory"]
}

I’m seeing the same behavior with our Nexus docker group (private repo + proxy for public images).

Docker version:

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:20 2018
 OS/Arch:      linux/amd64

Our /etc/docker/daemon.json:

{
  "insecure-registries":[
    "192.168.1.10"
  ],
  "registry-mirrors": [
    "http://192.168.1.10/nexus/repository/docker-group"
  ]
}

FWIW, this only seems to be an issue with Docker. Gems, Apt, YUM, NPM, and Maven can all pull through Nexus just fine.

For Nexus: follow this post https://mtijhof.wordpress.com/2018/07/23/using-nexus-oss-as-a-proxy-cache-for-docker-images. It allows you to serve the repo at a different port, mitigating the need for a path.

Any update on this? Not being able to use Nexus for our mirror is a huge pain

Hi. I just wanted to link this issue with the workaround described here https://github.com/goharbor/harbor/issues/8082#issuecomment-725694016 The solution works to me as a charm.

Nope, simply it means that this section of you config is ignored

,
{
  "registry-mirrors": ["https://artifactory.local.corp.net/artifactory"]
}

and mirroring doesn’t work as intended

But docker pull retrieves images. How does it know where to connect?

Since it’s a Nexus 3 registry-mirror, and not one that I’ve configured, that path is actually what points which of the repositories is a “docker-proxy”.

Removing it in 17.12.1 resulted in docker ignoring the registry-mirror and trying to fetch an image directly. Same in 17.09.0, however leaving the path there in 17.09.0 makes it work.