Skip to content

Instantly share code, notes, and snippets.

@vst
Last active March 11, 2020 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vst/32331b87b634330e9d9e2bbf1a726c8c to your computer and use it in GitHub Desktop.
Save vst/32331b87b634330e9d9e2bbf1a726c8c to your computer and use it in GitHub Desktop.
Setting up a Local Docker Registry

Setting up a Local Docker Registry

Note: Follow the official guide.

bash setup.sh myusername mypassword
  • Authentication information is stored under /data/docker/registry/auth.
  • Storage directory is set to be /data/docker/registry/storage.
  • Registry is running at http://localhost:5000
version: "3"
services:
registry:
restart: always
image: registry:2
ports:
- 5000:5000
volumes:
- /data/docker/registry/storage:/var/lib/registry
- /data/docker/registry/auth:/auth
#!/usr/bin/env bash
## Stop on errors:
set -e
## Get the username and password:
_USER="${1}"
_PASS="${2}"
## Check username and password:
if [ -z "${_USER}" ]; then
echo "Username is not provided. Exiting..."
exit 1
elif [ -z "${_PASS}" ]; then
echo "Password is not provided. Exiting..."
exit 1
fi
## Create required directories:
mkdir -p /data/docker/registry/{auth,storage}
## Update the password:
docker run --entrypoint htpasswd registry:2 -Bbn "${_USER}" "${_PASS}" > /data/docker/registry/auth/htpasswd
## Run the registry:
docker-compose -f registry.yml up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment