DEV Community

Dean
Dean

Posted on • Originally published at veducate.co.uk on

Authenticate Docker to Harbor Image Registry with a Robot Account

Just a quick blog post on how to authenticate Docker to a Harbor Image Registry, using a Robot Account, which is good for programmatically access to push/pull images from your registry.

Harbor introduced the capability for administrators to create system robot accounts you can use you run automated actions in your Harbor instances. System robot accounts allow you to use a robot account to perform maintenance or repeated task across all or a subset of projects in your Harbor instance.
Enter fullscreen mode Exit fullscreen mode

In Harbor, to create your robot account, within your project:

  • Click the Robot Accounts tab
  • Click New Robot Account
  • Enter your details as necessary and click save
  • Select export to file and save the JSON file.

Harbor - Create new robot account

Harbor - Create new robot account - fill out details

Harbor - export robot account

This file will be outputted with a โ€œ$โ€ in the name. You can either change the name of the file, or escape the character in the terminal, which I what Iโ€™ll be doing below.

Within your terminal run the following commands:

username=$(cat **file.json** | jq -r .name)
password=$(cat **file.json** | jq -r .token)
echo "$password" | docker login **https://URL** --username "$username" --password-stdin

**Example**
username=$(cat "robot\$veducate.json" | jq -r .name)
password=$(cat robot\$veducate.json | jq -r .token)
echo "$password" | docker login https://harbor-repo.veducate.com --username "$username" --password-stdin
Enter fullscreen mode Exit fullscreen mode

docker login

Now you can pull/push images to your repository using this authentication details.

Regards

Follow @Saintdle

Dean Lewis

The post Authenticate Docker to Harbor Image Registry with a Robot Account appeared first on vEducate.co.uk.

Top comments (0)