A Docker Registry v3 image with built-in HTTP basic authentication using htpasswd.
This project provides a ready-to-use Docker image that extends the official Docker Registry (version 3) with HTTP basic authentication. It automatically configures htpasswd-based authentication using environment variables, making it easy to deploy a secure, private Docker registry.
- Based on the official Docker Registry v3
- Automatic htpasswd authentication configuration
- Simple setup via environment variables
- Minimal dependencies (only adds apache2-utils for htpasswd)
user@local $ docker run -d \
-p 5000:5000 \
-e REGISTRY_USER=myuser \
-e REGISTRY_PASSWORD=mypassword \
--name registry \
mittwald/registry:3user@local $ mw container run \
-p 5000:5000 \
-e REGISTRY_USER=myuser \
-e REGISTRY_PASSWORD=mypassword \
--name registry \
mittwald/registry:3REGISTRY_USER: The username for registry authenticationREGISTRY_PASSWORD: The password for registry authentication
REGISTRY_AUTH_HTPASSWD_REALM: The realm name for authentication (default: "Registry Realm")
All standard Docker Registry environment variables are also supported. See the official Docker Registry documentation for more options.
Once the registry is running with authentication, you'll need to log in before pushing or pulling images. The examples assume your registry is running in the mittwald cloud, and that you have connected your registry container to a subdomain of the default p-XXXXXX.project.space subdomain.
# Log in to the registry
docker login registry.p-XXXXXX.project.space
# Tag an image
docker tag myimage:latest registry.p-XXXXXX.project.space/myimage:latest
# Push the image
docker push registry.p-XXXXXX.project.space/myimage:latest
# Pull the image
docker pull registry.p-XXXXXX.project.space/myimage:latestTo build the image yourself:
docker build -t mittwald/registry:3 .The auth-entrypoint.sh script:
- Validates that
REGISTRY_USERandREGISTRY_PASSWORDare set - Generates an htpasswd file with the provided credentials
- Sets the necessary registry authentication environment variables
- Passes control to the standard registry entrypoint
This project is licensed under the MIT License - see the LICENSE file for details.