How to add an authenticated DockerHub registry to Portainer and manage access to it

How to add an authenticated DockerHub registry to Portainer and manage access to it

Jack Wallen walks you through the process of adding an authenticated DockerHub registry to Portainer as well as granting users access to both the environment and the registry.

docker-with-waves.jpg
Illustration: Lisa Hornung/TechRepublic

Portainer is a powerful GUI tool you can use to manage most aspects of your Docker container deployment. But not only can you pull down images and deploy containers, but you can also add registries and even manage user access to those registries.

SEE: Business leaders as developer: The rise of no-code and low-code software (free PDF) (TechRepublic)

For example, you might have a team DockerHub account that you use for development images. Out of the box, Portainer uses anonymous access to DockerHub, so if you have a company account, it won’t pull from those images.

Fortunately, the Portainer developers have not only made it possible for you to add your authenticated DockerHub account, but you can also manage who has access to it within the GUI tool.

I’m going to show you how to do both.

What you’ll need

To make this work, you’ll need a running instance of Portainer and an access token for DockerHub.

How to create a DockerHub access token

The first thing we must do is create a DockerHub access token. Log into your DockerHub account and click the username drop-down in the upper-right corner of the window. From the drop-down menu, click Account Settings, and then, from the left sidebar, click Security. In the resulting window (Figure A), click New Access Token, give the token a name and make sure it has Read, Write, Delete access.

Figure A

Creating an access token for DockerHub.
Creating an access token for DockerHub.

Once you save the token, you’ll be presented with a long string of characters. Make sure to copy and save that access token, as you’ll need it in a bit.

How to add the authenticated DockerHub registry

Now, we’re going to add the authenticated DockerHub registry. Log into Portainer and click Registries from the left sidebar. In the resulting window (Figure B), click Add Registry.

Figure B

All of your registries will be listed here.
All of your registries will be listed here.

In the next window, click DockerHub along the top (Figure C).

Figure C

The types of registries you can add to Portainer are found at the top of the window.
The types of registries you can add to Portainer are found at the top of the window.

You will then have to fill out the necessary information for your authenticated DockerHub registry (Figure D). Give the new registry a name and then make sure the username is the actual username for your account (which is probably not the associated email address). In the password field, paste the access token here and then click Add Registry.

Figure D

Adding the authenticated DockerHub registry to Portainer.
Adding the authenticated DockerHub registry to Portainer.

Your registry is now ready to be used.

How to grant users access to the new registry

Let’s add a new user to Portainer and then grant them access to the DockerHub authenticated registry. From the left sidebar, click Users and then, in the resulting window type a new username and then type and confirm a password for the user (Figure E).

Figure E

Adding a new user to Portainer.
Adding a new user to Portainer.

Click Create User to add the new user to the system.

With our new user added, we then need to grant them access to the new registry. Before we can do that, we must first grant the new user access to the environment. For that, click Environments from the left sidebar and click Manage Access Associated with the local Environment. From the Select user(s) and/or team(s) drop-down (Figure F), select the new user and then click Create Access.

Figure F

Granting a user access to the environment.
Granting a user access to the environment.

Now, we can grant the user access to the new registry. From the left sidebar, click Host | Registries. In the next window, click Manage Access associated with the authenticated DockerHub registry.

Select the new user from the Select user(s) and/or team(s) drop-down and then click Create access (Figure G).

Figure G

Granting user Nathan access to the authenticated DockerHub registry.
Granting user Nathan access to the authenticated DockerHub registry.

When the new user logs into Portainer, they will not only have access to the necessary environment but to the DockerHub authenticated registry. This way they can pull the images your teams have created and pushed to your company’s DockerHub registry.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Source of Article