Docker Hub personal access tokens are created in Docker Home under your avatar → Account settings → Personal access tokens → Generate new token. You choose a repository permission level and an expiry (none, 30 days, 90 days or a custom date up to one year). Use the token as the password for docker login; it is shown only once.
Docker Hub key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Personal access token (PAT) The documentation pages used do not state a token prefix. | — | Yes | One repository permission level - Repo Public Read-only (default), Repo Read-only, Repo Read & Write, or Repo Read, Write, Delete - or No repository access; optional Cloud Sandboxes access | Default is none; options are 30 days, 90 days or a custom date up to one year. Expiry cannot be changed afterwards. |
How to create a Docker Hub key
- Sign in to Docker Home and verify your email if prompted.
- Select your avatar, then Account settings → Personal access tokens.
- Select Generate new token.
- Choose a repository permission level and an expiration.
- Generate the token and copy it; Docker shows it only once.
Limiting what the key can do
Choose the lowest repository permission that works: Repo Public Read-only, Repo Read-only, Repo Read & Write, or Repo Read, Write, Delete. A separate Allow Cloud Sandboxes access setting adds the sandbox:use scope.
How to rotate a Docker Hub key
- Generate a new token with the same permission level.
- Update the systems that run
docker loginwith the old token. - Deactivate and then delete the old token from its actions menu.
You cannot change the expiration of an existing token; create a new one instead.
How to revoke a Docker Hub key
- Open Account settings → Personal access tokens and use the token's actions menu.
- Choose Deactivate (reversible with Activate) or Delete; expired and revoked tokens can only be deleted.
If your Docker Hub key leaked
- Deactivate or delete the token immediately.
- Generate a replacement with the lowest permission level and a defined expiry.
- Review the repositories the token could write to for unexpected image pushes or deletions.
Environment variables and CLI
Docker CLI (docker): docker login --username <YOUR_USERNAME> and paste the personal access token when prompted for the password
Things that catch people out
- Docker shows the token once; save it immediately.
- The default permission is Repo Public Read-only, which cannot push; raise it only as needed.
- Docker Desktop can auto-generate up to five tokens and deletes the least recently used when a new one is created.
- Excessive token creation may lead to throttling or additional charges under Docker's fair use policy.
Recent incidents that put Docker Hub keys at risk
If you were affected by one of these, rotate your Docker Hub keys using the rotation steps above.
- GhostAction returns: fake security workflows pushed to 30,000+ repos to steal Actions secrets 2026-10-07
- 32 @redhat-cloud-services npm packages compromised after a VS Code extension hijacked a GitHub account 2026-06-01
- Trivy release, trivy-action and setup-trivy tags hijacked to steal CI/CD secrets 2026-03-21
- GhostAction: malicious GitHub Actions workflows stole 3,325 CI secrets from 817 repositories 2025-09-05
- tj-actions/changed-files compromise printed CI secrets into GitHub Actions logs 2025-03-14
Using your Docker Hub key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Docker Hub key, these intents fit:
| Intent | What BotPassword does |
|---|---|
list_credentials | Lists the credentials this agent is granted and what it may do with each. Never values. |
request_access | Asks you for a grant, which you approve with your master password or decline in BotPassword on your desktop, never in the chat. The agent gets a receipt, never a value. Approval on your phone is planned. |
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
cli_login | Lets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
capture_secret | Planned, not built yet: will read a newly created key straight from the page or command output into the vault. |
store_secret | Saves a value the agent already holds as a new vault item. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I create a Docker Hub access token?
In Docker Home select your avatar → Account settings → Personal access tokens → Generate new token.
How do I log in to Docker Hub with an access token?
Run docker login --username <YOUR_USERNAME> and paste the token when asked for the password.
Do Docker Hub access tokens expire?
By default no, but you can choose 30 days, 90 days or a custom date up to one year, and you cannot change it later.
How do I revoke a Docker Hub access token?
Use the token's actions menu to Deactivate it (reversible) or Delete it.
Can an AI agent use my Docker Hub key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with list_credentials, run_with, store_secret, so the agent gets the result and never the value.