Last active
March 19, 2018 08:00
-
-
Save steve-taylor/8363cd34919fac0b938726b9c05380db to your computer and use it in GitHub Desktop.
Private Docker registry with Let's Encrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export REGISTRY_DOMAIN=docker.example.com | |
export [email protected] | |
export REGISTRY_USER=docker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
mkdir -p volumes/registry/auth | |
read -sp "Enter a new password for user '${REGISTRY_USER}': " REGISTRY_PASS | |
docker run --rm --entrypoint htpasswd registry:2 -Bbn ${REGISTRY_USER} "${REGISTRY_PASS}" > volumes/registry/auth/htpasswd | |
docker run -d --name registry --restart=always \ | |
-p 5000:5000 \ | |
-v $(pwd)/volumes/registry/var/lib/registry:/var/lib/registry \ | |
-v $(pwd)/volumes/registry/auth:/auth \ | |
-e REGISTRY_HTTP_HOST=https://${REGISTRY_DOMAIN} \ | |
-e REGISTRY_AUTH_HTPASSWD_REALM=${REGISTRY_DOMAIN} \ | |
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ | |
registry:2 | |
docker run -d --name lets-nginx --restart=always \ | |
--link registry:registry \ | |
-p 80:80 \ | |
-p 443:443 \ | |
-v $(pwd)/volumes/lets-nginx/cache:/cache \ | |
-v $(pwd)/volumes/lets-nginx/etc/letsencrypt:/etc/letsencrypt \ | |
-e EMAIL=${DOMAIN_ADMIN_EMAIL} \ | |
-e DOMAIN=${REGISTRY_DOMAIN} \ | |
-e UPSTREAM=registry:5000 \ | |
smashwilson/lets-nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
docker stop lets-nginx | |
docker stop registry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment