mirror of
https://github.com/vimagick/dockerfiles.git
synced 2024-11-24 08:52:31 +02:00
.. | ||
docker-compose.oss.yml | ||
docker-compose.yml | ||
README.md |
registry
Registry is the Docker toolset to pack, ship, store, and deliver content.
docker-compose.yml
registry:
image: registry:2
ports:
- "5000:5000"
volumes:
- /etc/docker/registry
- ./data:/var/lib/registry
- ./certs:/certs
- ./auth:/auth
environment:
- REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt
- REGISTRY_HTTP_TLS_KEY=/certs/domain.key
- REGISTRY_AUTH=htpasswd
- REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
- REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
restart: always
frontend:
image: konradkleine/docker-registry-frontend:v2
ports:
- "8080:80"
- "8443:443"
links:
- registry
volume:
- ./certs/domain.crt:/etc/apache2/domain.crt
- ./certs/domain.key:/etc/apache2/domain.key
environment:
- ENV_DOCKER_REGISTRY_HOST=registry
- ENV_DOCKER_REGISTRY_PORT=5000
- ENV_DOCKER_REGISTRY_USE_SSL=1
- ENV_USE_SSL=yes
restart: always
Server Setup
$ mkdir -p ~/fig/registry/{auth,certs}
$ cd ~/fig/registry
$ openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt
$ docker-compose up -d
$ docker-compose exec registry sh
>>> htpasswd -Bbn username password >> /auth/htpasswd
>>> cat >> /etc/docker/registry/config.yml
proxy:
remoteurl: https://registry-1.docker.io
username: username
password: password
^D
>>> exit
$ docker-compose restart
⚠️ You cannot use it as registry+mirror at the same time.
Client Setup
$ scp registry.easypi.info:fig/registry/certs/domain.crt \
/etc/docker/certs.d/registry.easypi.info:5000/ca.crt
$ vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.easypi.info:5000"
],
"insecure-registries": [
"registry.easypi.info"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
$ systemctl reload docker
$ docker info
$ docker pull alpine
$ docker tag alpine registry.easypi.info:5000/alpine
$ docker login -u username -p password easypi.info:5000
$ docker push registry.easypi.info:5000/alpine
$ docker rmi registry.easypi.info:5000/alpine
$ docker pull registry.easypi.info:5000/alpine
$ firefox http://registry.easypi.info:8080
⚠️ Docker will connect insecure-registries via HTTPS first (ignore TLS error), then try HTTP.