Portus as a Distribution client

Miquel Sabaté Solà edited this page Apr 18, 2016 · 1 revision

The portus user

As explained in the documentation, Portus fetches the pushed image/tags and stores them into the database. In order to guarantee all the features available to users this is not enough though, and Portus has to act as a client of the Docker Distribution API. Moreover, every call to the registry will be re-routed to Portus again to check that the requesting user has the needed authorization level to perform such calls. For this reason, in Portus there has to be a special user with the name "portus", that has granted all the privileges to perform any API call. This user is creating on seeding time (rake db:seed). The password of this user has to be provided through the PORTUS_PASSWORD environment variable in production (in development we just define some random value).

Portus as a client of Docker Distribution's API

With the previous section in mind, we have implemented a very thin (and incomplete) client of the Docker Distribution API. The code of this client can be found in lib/portus/registry_client.rb. In order to test this, we use the bin/client.rb file. This is a Ruby on Rails runner and it exposes all the API calls that this client can perform. For this very reason, you should note that this should only be used for development/testing purposes. The header of this file contains all the information you might need to use it. As an example, imagine that you'd want to delete the manifest of a tag. First of all, you can retrieve the catalog by just executing:

$ rails runner bin/client.rb catalog

This will print to stdout all your images and all their tags. You can then fetch the manifest of a specific tag like this:

$ rails runner bin/client.rb manifest <image>:<tag>

This will print to stdout the full manifest of this image, and it will also tell you the manifest digest in a separate line. You can use this digest like this:

$ rails runner bin/client.rb delete <image> <digest> manifests

And with this you'd have deleted the given image manifest.