Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus Docker Registry - Failling anonymous pull

Tags:

I'm using Sonatype Nexus as a Private Docker Registry.

While it works with authenticated users, trying to use anonymous user to pull images doesn't work. This happens only on a docker client.

Using the Nexus UI (not logged in) I'm able to browse images on my repo. But trying to pull the images I get an 'Unauthorized' error.

The following is a capture stream of communication between the Docker Client and the Nexus repository:

Wireshark packet capture

This is strange, as the anonymous access is enabled, and according to the docs, I may have a Docker Hosted Registry (with RW access through HTTPs port) and a Docker Group Registry, pointing to a Docker Hosted Registry, with RO/Anonymous access.

like image 698
Ricardo Katz Avatar asked Apr 26 '16 21:04

Ricardo Katz


People also ask

Can we use Nexus as docker registry?

Installing Nexus Repository Manager using Helm ChartUsing this configuration, we can deploy the helm chart for nexus repository manager oss to work as an private docker registry. Once Installed Successfully, this is what the home page will look like: Nexus has a few repositories by default.

Can Nexus hold docker images?

Nexus Repository supports Docker images and Helm 3 repositories with Proxy, Hosted, and Group repositories, allowing users advanced container management capabilities across development teams.

How do I remove docker images from Nexus?

But basically 1) find the tags you want to delete listing them with the docker v2 api as reported in your quesiton. 2) delete those tags using the nexus asset API 3) set a nexus task of type "Delete unused docker manifests and blobs" 4) following this task, run a "compact blobstore" task to actually regain the space.


2 Answers

This feature was added in Nexus 3.6. According to the documentation:

  1. Under Security > Realms, enable the “Docker Bearer Token Realm”
  2. Uncheck “Force basic authentication” in the repository configuration
like image 137
andrewdotn Avatar answered Oct 29 '22 05:10

andrewdotn


Nexus caused me quite some headache until i found a rather obscure sonatype post that states not to change the anonymous realm.

So the steps I followed to get this working: (tested in Nexus 3.19.1 to 3.23.0)

  1. Same as the Answer by @andrewdotn (Enable the Docker Bearer Token Realm in the Security > Realms section)

  2. Enable the anonymous access FOR the Local Authorizing Realm (as stated in the above mentioned link)

  3. Create the docker(proxy) Repository (in this example to proxy hub.docker.com)

    3.1. enable the HTTP / HTTPS endpoint (depending if you ssl to nexus or use a reverse proxy)

    3.2. enable "Allow anonymous docker pull (Docker Bearer Token Realm required)"

    3.3. enter "https://registry-1.docker.io" as "Location of the remote repository" (for the docker-hub)

    3.4. set the "Docker Index" to use the docker hub index (aka.: "Use Docker Hub")

    3.5. save

  4. make sure your anonymous user has the right to read the new repository (the default anon-role will allow read access to quite a bit more, but should already allow anon pull)

    4.1. (OPTIONAL) If you want to restrict the anonymous user as much as possible (i.e.: to only allow docker pull) crate a role "nx-docker_read" (or similar) and give it the "nx-repository-view-docker--read"*. (this will allow the any user in the group to pull images from any docker repository, that allows anon pull, but not see anything on the web-ui)

    4.2. (if u did 4.1) now all that's left is to change the group of the anon user to ur new role (in my example "nx-docker_read") and remove it from "nx-anonymous" => anon-users can no longer brows nexus on the web-ui but can still pull images

like image 26
h1dden.da3m0n Avatar answered Oct 29 '22 05:10

h1dden.da3m0n