Authenticate Docker to Harbor Image Registry with a Robot Account
Tags: vmware, kubernetes, docker, harbor
Published: 2021-07-15 07:01:17

---
title: Authenticate Docker to Harbor Image Registry with a Robot Account
published: true
date: 2021-07-13 22:47:11 UTC
tags: VMware,Kubernetes,docker,Harbor
canonical_url: https://veducate.co.uk/authenticate-docker-harbor-robot/?utm_source=rss&utm_medium=rss&utm_campaign=authenticate-docker-harbor-robot
---

Just a quick blog post on how to authenticate Docker to a [Harbor Image Registry](https://goharbor.io/), 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.
```

In Harbor, to create your [robot account](https://goharbor.io/docs/2.2.0/administration/robot-accounts), 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](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-Create-new-robot-account.jpg?resize=604%2C217&ssl=1)](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-Create-new-robot-account.jpg?ssl=1)

[![Harbor - Create new robot account - fill out details](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-Create-new-robot-account-fill-out-details.jpg?resize=300%2C274&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-Create-new-robot-account-fill-out-details.jpg?ssl=1)

[![Harbor - export robot account](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-export-robot-account.jpg?resize=300%2C190&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Harbor-export-robot-account.jpg?ssl=1)

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
```

[![docker login](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/07/docker-login.jpg?resize=604%2C59&ssl=1)](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/07/docker-login.jpg?ssl=1)

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

Regards

[Follow @Saintdle](https://twitter.com/saintdle)<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

[Dean Lewis](https://uk.linkedin.com/in/saintdle?trk=profile-badge)

 

The post [Authenticate Docker to Harbor Image Registry with a Robot Account](https://veducate.co.uk/authenticate-docker-harbor-robot/) appeared first on [vEducate.co.uk](https://veducate.co.uk).