rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.96k stars 281 forks source link

registry-mirrors in daemon.json not working #3313

Open timacro opened 1 year ago

timacro commented 1 year ago

Problem Description

In order to use a custom registry, I created a daemon.json file at C:\Users\myaccount\.docker on my Windows 11 and added the registry-mirrors as follows:

{
    "registry-mirrors": [
        "https://docker.mirrors.ustc.edu.cn",
        "https://hub-mirror.c.163.com"
    ]
}

But it doesn't work. By executing docker info I got this message which has no field of registry-mirrors:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.6.1)
  extension: Manages Docker extensions (Docker Inc., v0.2.9)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.19.0)

Server:
 Containers: 26
  Running: 26
  Paused: 0
  Stopped: 0
 Images: 11
 Server Version: 20.10.18
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: 5fd4c4d144137e991c4acebb2146ab1483a97925
 init version:
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.15.68.1-microsoft-standard-WSL2
 Operating System: Rancher Desktop WSL Distribution
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.58GiB
 Name: T10
 ID: HH53:BM2Z:CYIH:4HXS:OYTH:Q6WI:U4BP:HQWF:EEJT:OQIC:IISZ:WSXT
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Any idea ?

Proposed Solution

Any possible solution.

Additional Information

No response

jandubois commented 1 year ago

The file must be created inside the rancher-desktop distro, at /etc/docker/daemon.json.

You can run rdctl shell to run a shell inside the distro.

You should be able to copy the file over with cp /mnt/c/myaccount/.docker/daemon.json /etc/docker.

I'm not sure if you have to make sure the file has Linux line-endings or not.

You will need to stop and re-start Rancher Desktop for the change to take effect, and it will be lost if you ever do a Factory Reset.

jack-liew commented 1 year ago

hi: do not use docker' daemon.json. u should in wsl'rancher-desktop to setup registry configure file.

i use cellphone now, so can not give u an accurate answer, the configure file maybe is /var/lib/rancher/k3s/…/registry.yaml. it should like : mirrors: "node1:30001": ……

Niklas2501 commented 1 year ago

Hey, i'm also trying to setup a docker.io mirror in Rancher Desktop and i'm facing the same issue. I tried to follow @jandubois steps but doing so does not seem to have any effect.

I also tried the approach described in this issue of adding a script to the override.yaml to create a registry.yaml but wasn't successful with this one either.

Any other ideas to get a mirror running?

Details: Rancher Desktop Version: 1.7.0 Kubernetes Version: v1.25.4 OS: MacOs 13.1 on a M1 ARM

xbj110825 commented 1 year ago

When using an older version of docker(such as 1.13), dockerd seems ignore the registry-mirrors parameter in daemon.json, you should add --registry-mirror as command line arg instead. /usr/bin/dockerd --registry-mirror https://foo.bar