Settting up a Container Registry with docker-gitlab
This should use help to setup the container registry feature with docker-gitlab.
- Docker Distribution >= 2.4
- Docker GitLab >= 8.8.0
- TLS certificates because it should be run with https it's not designed to use it without https
First of all run a docker distirbution container here is a registry connfiguration example:
config.yml
version: 0.1
log:
level: info
formatter: text
http:
addr: 0.0.0.0:5000
secret: <yoursecret>
tls:
certificate: </certs/fullchain.pem> # TLS certificate of the registry Domain
key: </certs/privkey.pem> # Privatekey for the TLS Certificate
storage:
filesystem:
rootdirectory: /var/lib/registry
delete:
enabled: true
auth:
token:
realm: https://<yourGitLabDomain>/jwt/auth
service: container_registry
issuer: <gitlab-issuer>
rootcertbundle: </certs/fullchain.pem>
Every <placeholder> should be replaced by your own configuration.
Important! Do not change the service and the realm endpoint. This leads to cruel errors.
docker-compose.yml
version: '2'
services:
registry:
restart: always
image: registry:2.4.1
ports:
- '5000:5000'
volumes:
- ./data:/var/lib/registry
- ./certs:/certs
- ./auth:/auth
- ./config.yml:/etc/docker/registry/config.yml
docker-compose.yml
version: '2'
services:
redis:
restart: always
image: sameersbn/redis:latest
command:
- --loglevel warning
volumes:
- ./redis:/var/lib/redis
postgresql:
restart: always
image: sameersbn/postgresql:9.4-21
volumes:
- ./postgresql:/var/lib/postgresql
enviroment:
- DB_USER=gitlab
- DB_PASS=<yourdatabasepassword>
- DB_NAME=gitlabhq_production
- DB_EXTENSION=pg_trgm
gitlab:
restart: always
image: sameersbn/gitlab:8.8.0
volumes:
- ./gitlab:/home/git/data
- ./log/:/var/log/gitlab
- <registryPath>/data:/home/git/data/shared/registry
- ./certs:/home/git/certs
ports:
- "2222:22"
- "5005:5005"
depends_on:
- redis
- postgresql
enviroment:
- DB_HOST=postgresql
- DB_PORT=5432
- DB_TYPE=postgres
- DB_USER=gitlab
- DB_PASS=<yourdatabasepassword>
- DB_NAME=gitlabhq_production
- REDIS_HOST=redis
- REDIS_PORT=6379
- GITLAB_SSH_PORT=2222
- GITLAB_HOST=<yourGitLabDomain>
- GITLAB_SECRETS_DB_KEY_BASE=<DB SECRET KEYS>
- GITLAB_REGISTRY_ENABLED=true
- GITLAB_REGISTRY_HOST=<Your Gitlab Container Registry Domain>
- GITLAB_REGISTRY_PORT=<5005>
- GITLAB_REGISTRY_API_URL=<https://<yourRegistryDomain:5000/>
- GITLAB_REGISTRY_KEY_PATH=</home/git/certs/privkey.pem>
- GITLAB_REGISTRY_PATH=<shared/registry>
- GITLAB_REGISTRY_ISSUER=<gitlab-issuer>
- SSL_REGISTRY_KEY_PATH=</home/git/certs/docker-registry.key>
- SSL_REGISTRY_CERT_PATH=</home/git/certs/docker-registry.crt>
A few things I have learned during the setup of my Gitlab/Registry System:
config.ymlis optional. Gitlab acts as a Reverse Proxy/SSL Termination for the registry. If you do drop the TLS section, change theGITLAB_REGISTRY_API_URLto `http://.rootcertbundlecan point to ANY certificate, the only requirement is thatGITLAB_REGISTRY_KEY_PATHpoints to the corrosponding private key of this certificate. I tested this with an expired key-pair for another domain and it worked just fine. I created my key-pair (certificate) like this:issuerandGITLAB_REGISTRY_ISSUERhave to match