dockerartifactorydockerhub

How to mirror dockerhub with artifactory


Since dockerhub has started limiting downloads for non-paid accounts, I am frequently getting this error

ERROR: Preparation failed: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (executor_docker.go:188:15s)

https://docs.docker.com/docker-hub/download-rate-limit/

I have an artifactory server, how can I setup docker to cache/mirror from artifactory first?


Solution

  • First setup an artifactory remote that points to docker hub at https://registry-1.docker.io

    enter image description here

    Then reconfigure all docker agents to use the registry_mirror. There are multiple ways to do this, but adding --registry-mirror to the docker start up options is most likely the easiest. See the docker documentation for more information

    https://docs.docker.com/registry/recipes/mirror/

    Method 1

    Add --registry-mirror to the OPTIONS variable in /etc/default/docker

    cat /etc/default/docker
    OPTIONS=" -H unix:///var/run/docker.sock --ip-forward=true --iptables=true --ip-masq=true --registry-mirror=https://docker.artifactory.example.com -G docker"
    
    

    Method 2

    Edit /etc/docker/registry/config.yml

    proxy:
      remoteurl: https://registry-1.docker.io
      username: [username]
      password: [password]
    

    Method 3

    If using puppet the config looks like this

      class { '::docker':
        use_upstream_package_source => false,
        manage_package              => false,
        registry_mirror             => 'https://docker.artifactory.example.com',
      }