Jump to content

This is a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Docker-registry

From Wikitech

We run our own Docker registry at docker-registry.wikimedia.org . Internally the domain docker-registry.discovery.wmnet is also used. The registry is used by our k8s cluster, CI, and local development.

It is highly available ( docker_registry_ha Puppet module) and backed by S3 (via the apus Ceph cluster). We run it active/passive since we don't fully trust the Ceph's bi-directional replication between eqiad and codfw.

The docker-registry nodes consist of the docker registry itself as well as an nginx reverse-proxy in front to handle authentication as well as local caching .

Supported use cases

The Docker Registry supports all the Wikimedia production/internal use cases, and we allow Docker pulls from external clients as best effort. Please do not add our Docker Registry as additional source in your configs; any recurrent pull attempt for non existing images will be eventually blocked.

Browsing

Visit https://docker-registry.wikimedia.org/ to see a list of images and their tags. The listing is updated on a hourly timer and is done by the registry-homepage-builder.py script in Puppet.

Downloading images

Despite the name, the docker-registry is usable by any OCI container tool, including podman. Nearly all images may be publicly downloaded, examined, run, etc. The only exception is images under the restricted/ namespace, which contain non-disclosed security patches and require specific credentials to fetch.

Kubernetes nodes use Dragonfly to pull images.

Uploading images

For services we recommend using the Deployment pipeline which is Blubber .

For other docker images, like infrastructure images, we manage them using docker-pkg, see: Kubernetes/Images#Image_building

Hosts that want to upload images must be individually listed in Puppet hiera.

Access control

The upstream docker-registry software provides no access control, so it is implemented at the nginx level, which restricts GET/POST/etc. requests accordingly. As of 2021-03-18, the following accounts exist:

  • ci-restricted : Can pull and push any image (including "restricted/"). Used by releases servers that build the restricted MediaWiki production image.
  • ci-build : Can pull and push any non-restricted image. Used by contint servers via docker-pkg and the deployment pipeline.
  • prod-build : Can pull and push any non-restricted image. Used by build2001.codfw.wmnet via docker-pkg and build-base-images.
  • kubernetes : Can pull any image (including "restricted/"). Used by k8s nodes to pull images, including the restricted MediaWiki production image.

The passwords are all deployed using the private puppet repo. In case rotation is needed (e.g. compromise), grepping for <name>_user_password should find all uses (switch hyphens to underscores).

jwt-authorizer

docker-registry also supports authorization using JSON Web Tokens. A dedicated daemon is running which handles jwt validation. See Docker-registry/jwt-authorizer for more information.

Storage backends

These are the S3 buckets that we use (Oct 2026):

  • An S3 bucket (restricted) for /v2/restricted.* images.
  • An S3 bucket (ml) for /v2/wikimedia/machinelearning.* , /v2/repos/machine-learning/.* images (and their vllm base images).
  • An S3 bucket (releng) for /v2/releng.* , /v2/repos/releng.* images.
  • An S3 bucket (main) for all the other images running on Kubernetes clusters.

Every S3 bucked is managed by a Docker Distribution instance, and the Nginx proxy in front of them routes requests based on their prefix name.

Migration from Swift to S3

More info are tracked in https://phabricator.wikimedia.org/T427175. The migration is fully done but we keep this guide in case some images haven't been copied correctly.

We use skopeo (from Debian's upstream) to copy over images from one Docker Distribution instance to the other one, preserving the sha256 signatures of the blobs etc.. This is very handy when migrating images from Swift to a new S3 bucket! If it happens that an image has not been copied over and the Nginx config for a given prefix is already pointing to the new S3 bucket/distribution combo, it is sufficient to use skopeo to quickly fill the gap.

For example, let's say that you get a report of docker-registry.wikimedia.org/releng/rake-ruby3.3:0.1.0 missing from the registry (docker pull errors etc..), you can do the following:

  • ssh to registry1004 (standby host, you can also use any of the other ones).
  • Start the Swift Registry Docker Distribution daemon via sudo -u docker-registry /usr/bin/docker-registry serve /home/elukey/config-swift.yml
  • Check if the image is present on the Swift backend
# Note: From docker-registry.wikimedia.org/releng/rake-ruby3.3:0.1.0
# you need to replace "docker-registry.wikimedia.org" with "/v2" 
# Note2: localhost:5000 is the address of the Docker Distribution backend for Swift
elukey@registry1004:~$ curl http://localhost:5000/v2/releng/rake-ruby3.3/tags/list
{"name":"releng/rake-ruby3.3","tags":["0.1.0","latest"]}
  • If it is not present, the issue may not be related to the S3 migration.
  • If it is present, you need to figure out what is the S3 destination bucket. In this case, /v2/releng is a prefix matching the Releng's Docker distribution daemon. To find what is the right target, check the beginning of the tutorial.
    • Find the port it is listening on, in this case 5006
      elukey@registry1004:~$ sudo grep addr /etc/docker/registry/config-releng.yml 
        addr: ":5006"  <====================
          addr: ":5007"
        addr: rdb1015.eqiad.wmnet:6382
        - addr: rdb1015.eqiad.wmnet:6382
      
  • And finally, you can execute the following command to copy the image layers / manifests / etc.. over:
# Note: remove the /v2/ prefix since it is not related to the Docker image's name!

skopeo copy --all --preserve-digests docker://localhost:5000/releng/rake-ruby3.3:0.1.0 docker://localhost:5006/releng/rake-ruby3.3:0.1.0 --dest-tls-verify=false --src-tls-verify=false

That's it! The image should be available again for pulls.

Deleting images

To delete an image entirely, you may use the tool docker-registryctl on the current build host. It will do it's best to remove the tags/image from the registry, despite the circumstances . Note: the domain used here is important. discovery.wmnet has to be used, so you will have to adjust it if you copy and paste from the browser UI.

elukey@build2004:~$ sudo -i docker-registryctl delete-tags docker-registry.discovery.wmnet/wikimedia/machinelearning-liftwing-inference-services
We're about to delete the following tags for image docker-registry.discovery.wmnet/wikimedia/machinelearning-liftwing-inference-services:
2021-07-28-175322-production
stable
Ok to proceed? (y/n)y
docker-registry.discovery.wmnet/wikimedia/machinelearning-liftwing-inference-services:2021-07-28-175322-production[DONE]
docker-registry.discovery.wmnet/wikimedia/machinelearning-liftwing-inference-services:stable[GONE]

The underlying data isn't yet automatically garbage-collected from the S3 backend storage ( https://phabricator.wikimedia.org/T437297 ), but the image(s) will no longer be available for download. Note that they will still show up on the docker-registry homepage (e.g. https://docker-registry.wikimedia.org/golang1.25/tags/ ) for a bit, this list is rebuilt only every hour.

If you want to delete MediaWiki images under the /restricted namespace:

# Note the hostname change! The credentials are at the moment (October 2026) on deploy1003

# Delete all images with tag matching September 2026
elukey@deploy1003:~$ sudo docker-registryctl -c /etc/docker-pusher/config.json  delete-tags docker-registry.discovery.wmnet/restricted/mediawiki-singleversion-cli:2026-09*

# If you want to restrict images older than a certain date in the tag and from 2026
elukey@deploy1003:~$ sudo docker-registryctl -c /etc/docker-pusher/config.json  delete-tags docker-registry.discovery.wmnet/restricted/mediawiki-singleversion-cli:2026* --older-than 2026-09-30

Please note that it may take a bit of time since the bigger the S3 bucket the more checks the Docker Registry's S3 client code needs to do to find the exact sha256 of the manifest to drop. Be patient :)

Run the Registry's Garbage collector

As mentioned in the previous section, docker-registryctl only drops image manifests from the Registry, the binary files corresponding to layers etc.. stay on S3. In order to remove them, the Docker Distribution binary needs to run with special GC settings; for example, let's assume we want to launch it for the restricted bucket:

elukey@registry1004:~$ sudo -u docker-registry /usr/bin/docker-registry garbage-collect /etc/docker/registry/config-restricted.yml

The hosts to execute the command on can be any of the registry ones, but one caveat needs to be kept in mind: it is highly suggested to set the Registry in read-only mode before doing it (note: since we have multiple Docker Distribution services running on the same host, it will be sufficient to set read-only the one that handles the S3 bucket that you want to clean). Some important notes:

  • Use the "-m" parameter with care, since it will cause the Mark phase to take way longer than needed. In our setup it shouldn't be needed anyway.
  • The Mark and Sweep (S3 deletes) phases take some time to be executed, so plan the read-only maintenance window accordingly (ballpark figures, consider a couple of hours minimum).
  • In some cases, like the restricted bucked/endpoint, it will be sufficient to stop the clients from pushing new images with something like scap lock. So you can be creative and avoid to explicitly set the Registry read-only in hiera.

Maintenance

The docker-registry nodes consist of the docker registry itself as well as an nginx reverse-proxy in front to handle authentication as well as local caching .

Service management

The following units run on the registry nodes:

Service unit Description
docker-registry-ha-jwt.service JSON Web Token authoriser
docker-registry-main.service Catch all instance for Kubernetes workloads.
docker-registry-ml.service Registry instance serving the ML/LiftWing namespace
docker-registry-restricted.service Registry instance serving MediaWiki restricted images
docker-registry-releng.service Registry instance serving releng-related images.

Restarting

Before restarting any service, confirm which node is currently active and prefer restarting the passive node where possible to avoid unnecessary disruption.

cumin1003:$ sudo  confctl --object-type  discovery select 'dnsdisc=docker-registry' get
sudo systemctl restart docker-registry-ha-jwt.service
sudo systemctl restart docker-registry-swift.service
sudo systemctl restart docker-registry-ml.service
sudo systemctl restart docker-registry-restricted.service

To check status:

sudo systemctl status docker-registry-ha-jwt.service

Note that nginx sits in front of all registry instances and handles authentication and local caching.

sudo systemctl status nginx.service
sudo systemctl restart nginx.service

Post-restart verification - httpbb

Run the httpbb tests against the restarted node to confirm it is serving correctly. Make sure the instance is not in read-only mode first ( profile::docker_registry::read_only_mode: false ):

sudo httpbb /srv/deployment/httpbb-tests/docker-registry/test_docker-registry.yaml --hosts 'registry2004.codfw.wmnet'

See also