Skip to content

Instantly share code, notes, and snippets.

@OzieWest
Last active January 20, 2017 09:29
Show Gist options
  • Select an option

  • Save OzieWest/ddc772263dcf8008cf437d6a980bfb7a to your computer and use it in GitHub Desktop.

Select an option

Save OzieWest/ddc772263dcf8008cf437d6a980bfb7a to your computer and use it in GitHub Desktop.
Setup your Private Docker Registry

Running on localhost

Start your registry:

docker run -d -p 5000:5000 --restart=always --name registry registry:2

Use a Storage Volume

By default, your registry data is persisted as a docker volume on the host filesystem. Properly understanding volumes is essential if you want to stick with a local filesystem storage.

Specifically, you might want to point your volume location to a specific place in order to more easily access your registry data. To do so you can:

docker run -d -p 5000:5000 --restart=always --name registry \
  -v `pwd`/data:/var/lib/registry \
  registry:2

Running a domain registry

While running on localhost has its uses, most people want their registry to be more widely available. To do so, the Docker engine requires you to secure it using TLS, which is conceptually very similar to configuring your web server with SSL.

Get a certificate

Assuming that you own the domain myregistrydomain.com, and that its DNS record points to the host where you are running your registry, you first need to get a certificate from a CA.

Or else you can have your self signed certificate as described in this article.

Create a certs directory:

mkdir -p certs

Then move and/or rename your crt file to: certs/domain.crt, and your key file to: certs/domain.key.

Make sure you stopped your registry from the previous steps, then start your registry again with TLS enabled:

docker run -d -p 5000:5000 --restart=always --name registry \
  -v `pwd`/certs:/certs \
  -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
  -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
  registry:2

Source: https://medium.com/@kasun.dsilva/setup-your-private-docker-registry-5eb81bbd3fc9#.pk1es186z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment