## TL;DR

Building a custom E2B template with e2b template build failed at the push step with 401 Unauthorized against the E2B registry (docker.e2b.dev), even after e2b auth logout + e2b auth login, restarting Docker, and manually adding registry credentials to ~/.docker/config.json.

## Steps

1. Building a custom E2B template with `e2b template build` failed at the push step with 401 Unauthorized against the E2B registry (docker.e2b.dev), even after `e2b auth logout` + `e2b auth login`, restarting Docker, and manually adding registry credentials to ~/.docker/config.json. The Docker build itself completed fine , only pushing the image was rejected. Affected CLI 0.5.10 with Docker 27.x.

2. E2B fixed this in @e2b/[email redacted] and later , run `npm i -g @e2b/cli@latest`. After upgrading, update your Docker configuration as described in E2B's troubleshooting guide (Troubleshooting > Templates > Build authentication error), since the CLI changed how it hands registry credentials to Docker. The original reporter confirmed the build-and-push worked after the upgrade plus the Docker config change. Source: https://github.com/e2b-dev/E2B/issues/450

## When to use

You are seeing this: The Docker build itself completed fine , only pushing the image was rejected. Use this skill when you run into "401 Not Authorized when `e2b template build` pushes the container".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: CLI 0.5.10. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Sources

- https://github.com/e2b-dev/E2B/issues/450
