8000 GitHub - pranay-91/docker_registry: Docker compose file for setting up local docker registry instance with basic authentication
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pranay-91/docker_registry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Setting up local docker registry

Deploying a registry server on a local instance/server. This example demonstrates native basic auth and using TLS or similar to webserver with SSL.

Directory structure:

"auth" is to store credentials. "certs" is for certificates using TLS and "data" is for storing images on registry.

  -./root
    -./auth
    -./certs
    -./data

Steps:

  • Get a certificate

    • Create a certificate directory. Make sure to use the correct name as a CN. Eg: localhost or myregistrydomain.com

      mkdir -p certs
      openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt
    • Copy the domain.crt file to /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt on every Docker host. In this example directory certs.

  • Basic Authentication

    • Create a auth directory and generate a user "testuser" with password "testpassword".
      mkdir auth
      docker run --entrypoint htpasswd registry:2 -Bbn testuser testpassword > auth/htpasswd
    • In order to add more users.
      docker run --entrypoint htpasswd registry:2 -Bbn testuser2 testpassword2 >> auth/htpasswd
  • Run docker registry

    • Pull dokcker registry2 image
      docker pull registry:2
    • Using docker run
      docker run -d -p 6000:5000 --restart=always --name registry \
      -v `pwd`/auth:/auth \
      -e "REGISTRY_AUTH=htpasswd" \
      -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
      -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
      -v `pwd`/certs:/certs \
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
      -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
      registry:2
    • Using docker compose
      registry:
        restart: always
        image: registry:2
        ports:
          - 6000:5000
        environment:
          REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
          REGISTRY_HTTP_TLS_KEY: /certs/domain.key
          REGISTRY_AUTH: htpasswd
          REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
          REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
        volumes:
          - ./data:/var/lib/registry
          - ./certs:/certs
          - ./auth:/auth
      
      Note: Replace volumes .\data .\certs .\auth with your own local directory.
  • Using local registry

    • Login. Enter credentials "testuser" and password "testpassword"
      docker login localhost:6000
    • Access local registry
      docker pull node
      docker tag node localhost:6000/node
      docker push localhost:6000/node
      docker pull localhost:6000/node
    • Logout from local registry
      docker Logout localhost:6000
    • Similarly you can login using different credentials via docker login command.

Useful Links

About

Docker compose file for setting up local docker registry instance with basic authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0