Skip to content

Fix Portainer Registry Auth – Unable to Pull from Private Registry

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Fix Portainer Registry Auth. We cover key concepts, practical examples, and best practices.

You configure a private container registry in Portainer (Docker Hub, GitLab, AWS ECR, or self‑hosted), then try to deploy a stack or container using an image from that registry. The deployment fails: "Error response from daemon: unauthorized: No basic auth credentials".

Wrong ❌

# docker-compose.yml
services:
  app:
    image: registry.gitlab.com/my-org/my-app:latest

In Portainer, you add the registry:

```text
Registry β†’ Add registry β†’ GitLab
URL: registry.gitlab.com
Token: glpat-abc123

But the stack deploy still fails:

unauthorized: HTTP Basic: Access denied

The token is correct β€” you can pull from your local machine. The issue: Portainer's registry credentials aren't being passed to the deployment.

## Right βœ…

**Step 1 β€” Add the registry correctly:**

1. **Settings β†’ Registries β†’ Add registry**
2. Choose **GitLab** (or Docker Hub, ECR, Quay, Custom)
3. Fill in:
   - **Name:** GitLab Registry
   - **URL:** `registry.gitlab.com`
   - **Authentication:** β˜‘
   - **Username:** your‑username
   - **Password / Token:** `glpat-abc123` (or access token)
4. **Manage access:** Tick the environment(s) where the registry should be used
5. Click **Add**

**Step 2 β€” Check environment associations:**

1. **Registries** β†’ click your registry
2. Under **Authorized Environments**, ensure the target Docker environment is ticked

**Step 3 β€” Deploy the stack/container again:**

βœ… Pulling image registry.gitlab.com/my-org/my-app:latest...
βœ… Image pulled successfully (12 MB)
βœ… Container started

**For AWS ECR:**

```bash
# In Portainer registry settings:
Type: Amazon ECR
Region: us-east-1
Access Key ID: AKIA...
Secret Access Key: ...

Portainer automatically refreshes ECR tokens (12‑hour expiry).

**For custom registries:**

```yaml
# Registry config in Portainer:
Type: Custom
URL: docker.mycompany.com:5000
Authentication: β˜‘
Username: deploy
Password: ****

## Root Cause

Portainer stores registry credentials globally but only passes them to environments where the registry is **authorised**. If the environment isn't associated, the Docker daemon on the node doesn't receive the credentials and fails with "No basic auth credentials".

## Prevention

- After adding a registry, immediately check the **Authorized Environments** tab.
- Use **Registry mirror** for public registries behind a corporate firewall.
- For production, use a dedicated **Robot Account** with read‑only scoped tokens.
- Regularly rotate registry passwords β€” Portainer notifies if a credential is invalid.


## Common Mistakes with registry auth

1. **Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors**
2. **Non-exhaustive pattern matches that compile with warnings then crash at runtime**
3. **Misunderstanding that `String` is `[Char]` with poor performance for large text operations**

These mistakes appear frequently in real-world PORTAINER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

## Practice Exercise

**Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.**

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

## FAQ

<details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: Can I use the same registry across multiple Portainer environments?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: Yes β€” tick all applicable environments in the registry's <strong>Authorized Environments</strong> settings.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: Why does my GitLab token work from CLI but not Portainer?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: GitLab tokens require the <code>read_registry</code> scope. Verify the token has the correct scopes in GitLab β†’ Settings β†’ Access Tokens.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: Does Portainer support OCI (Open Container Initiative) registries?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: Yes β€” any registry conforming to the OCI distribution spec works with the <strong>Custom</strong> registry type.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: How do I debug registry pull failures?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: In Portainer, go to <strong>Environment β†’ Logs</strong> and search for <code>unauthorized</code> or <code>no basic auth</code>. Or SSH into the node and run <code>docker login</code> manually.</p>
</div></details>

---

*Registry management is covered in the [DodaTech Portainer Registries course](https://dodatech.com/courses/portainer).*

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro