# Docker Hub: credentials

Under Connections, category Docker registries, you store Docker Hub with an access token. GitHub hosting requires this connection so builds can push images there and GitOps can pull them.

> Source: https://www.mainpath.ai/en/docs/docker-hub-credentials/

**Docker Hub** lives under **Connections** in the **Docker registries** category. Docker does **not** offer third-party OAuth for registry login; MainPath therefore checks username and **personal access token** against the Docker Hub login API.

When a project is hosted on **GitHub**, a Docker Hub connection is required. GitLab.com and self-hosted GitLab use that GitLab instance's container registry, see [GitLab: credentials]({{< relref "gitlab-credentials" >}}).

## Access token

1. In Docker Hub, under **Account Settings → Personal access tokens**, create a token with **Read, Write, Delete** on the registry (at least Read & Write).
2. Open **Connections → Docker registries → Docker Hub**.
3. Enter **Name**, **Slug**, **Username** (Docker ID), and the token. **Namespace** is optional: leave it empty to use the Docker ID, or an organization you can push to.

MainPath checks the credentials with a login against `hub.docker.com`. The token is stored in OpenBao, not in git in plaintext.

## Use it on a project

On the project, under **Repositories**, the **Docker registry** picker appears as soon as at least one component or GitOps uses **GitHub**.

Images are named `docker.io/<namespace>/<project-slug>-<component>`, for example `docker.io/acme/student-pro-backend`. GitHub Actions writes `.github/workflows/docker-publish.yml` and sets the secrets `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN`. GitOps pulls the same names.

Without a Dockerfile in the repository the publish job is skipped.

## What is not available

- OAuth against Docker Hub for registry login
- Nested paths like GitLab (`group/project/backend`); Docker Hub only has `namespace/name`

