A self-hosted Docker registry with a web UI.
- Docker
- Docker Compose
- Existing SSL certificates
docker-registry/
βββ auth/
β βββ htpasswd
βββ certs/ (add your certs here)
β βββ domain1/ (add your domain and its certs here)
β βββ fullchain.pem
β βββ privkey.pem
βββ data/
βββ .env
βββ docker-compose.yml
βββ README.md
-
Create required directories:
mkdir -p auth certs data
-
Create
.env
file:# Domain Configuration REGISTRY_DOMAIN=domain1.lan REGISTRY_PORT=5555 REGISTRY_UI_PORT=8080 # Protocol Configuration REGISTRY_UI_PROTOCOL=http REGISTRY_PROTOCOL=https # SSL Certificate Paths SSL_CERT_DIR=./certs SSL_DOMAIN_DIR=domain1.lan SSL_CERT_FILE=fullchain.pem SSL_KEY_FILE=privkey.pem # Auth Configuration REGISTRY_USER=admin REGISTRY_PASSWORD=yourpassword
-
Create authentication credentials:
# Note: Replace 'admin' and 'yourpassword' with your desired credentials # Make sure these match REGISTRY_USER and REGISTRY_PASSWORD in your .env file docker run --entrypoint htpasswd httpd:2 -Bbn admin yourpassword > auth/htpasswd
-
Place your SSL certificates:
- Place your SSL certificates in the directory specified by your environment variables:
# Example path based on default .env values: # ./certs/domain1.lan/fullchain.pem # ./certs/domain1.lan/privkey.pem
-
Start the registry:
docker-compose up -d
Scroll down for a Practical Example using helloworld to test your new registry
docker login ${REGISTRY_DOMAIN}:${REGISTRY_PORT}
# Tag your image
docker tag your-image:tag ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/your-image:tag
# Push to registry
docker push ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/your-image:tag
docker pull ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/your-image:tag
Access the registry UI at: ${REGISTRY_UI_PROTOCOL}://${REGISTRY_DOMAIN}:${REGISTRY_UI_PORT}
Username: ${REGISTRY_USER} (as set in .env and htpasswd)
Password: ${REGISTRY_PASSWORD} (as set in .env and htpasswd)
docker-compose logs -f
docker-compose down
The registry data is stored in the data directory. Back up this directory along with the auth and certs directories.
Practical Example Using Hello World with http, domain1.lan, port 5555 for registry, port 8080 for UI
Here's a complete example to test your registry:
# Pull hello-world from Docker Hub
docker pull hello-world
# Tag for your private registry
docker tag hello-world domain1.lan:5555/hello-world
# Check image is tagged
docker images
# Push to your registry
docker push domain1.lan:5555/hello-world
# Verify in UI
Visit http://domain1.lan:8080 and you should see 'hello-world' listed
# Test pulling
docker rmi hello-world domain1.lan:5555/hello-world
docker pull domain1.lan:5555/hello-world
docker run domain1.lan:5555/hello-world