Skip to content

Instantly share code, notes, and snippets.

@zoonderkins
Created March 15, 2022 10:38
Show Gist options
  • Save zoonderkins/7d2a6e734b4f7e70a1cd14232e6c1403 to your computer and use it in GitHub Desktop.
Save zoonderkins/7d2a6e734b4f7e70a1cd14232e6c1403 to your computer and use it in GitHub Desktop.
Setup self-hosted docker registry

Setup

https://docs.docker.com/registry/deploying/

Make a directory and setup docker compose

mkdir /root/docker-registry

mkdir /root/docker-registry/auth

Setup auth

https://docs.docker.com/registry/deploying/#restricting-access

cd /root/docker-registry/auth

docker run \
  --entrypoint htpasswd \
  httpd:2 -Bbn testuser testpassword > auth/htpasswd
  

Final setup docker-compose

nano /root/docker-registry/docker-compose.yml


version: '3.3'
services:
    docker-registry:
        ports:
          - '5000:5000'
        restart: always
        container_name: registry
        volumes:
            - './registry:/var/lib/registry'
            - './auth:/auth'
        environment:
            - 'REGISTRY_AUTH=htpasswd'
            - 'REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm'
            - REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
        image: 'registry:latest'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment