1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-28 09:41:20 +00:00
dockerfiles/registry/README.md

99 lines
2.5 KiB
Markdown
Raw Normal View History

2016-06-18 06:57:59 +00:00
registry
========
[Registry][1] is the Docker toolset to pack, ship, store, and deliver content.
## docker-compose.yml
```yaml
registry:
2016-08-29 00:13:48 +00:00
image: registry:2
2016-06-18 06:57:59 +00:00
ports:
- "5000:5000"
volumes:
2016-08-27 11:44:32 +00:00
- /etc/docker/registry
2016-06-18 06:57:59 +00:00
- ./data:/var/lib/registry
- ./certs:/certs
- ./auth:/auth
environment:
2016-08-29 00:13:48 +00:00
- REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt
- REGISTRY_HTTP_TLS_KEY=/certs/domain.key
2016-06-18 06:57:59 +00:00
- REGISTRY_AUTH=htpasswd
- REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
- REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
restart: always
2016-08-29 00:13:48 +00:00
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
2016-06-18 06:57:59 +00:00
```
2016-08-29 00:13:48 +00:00
## Server Setup
2016-06-18 06:57:59 +00:00
```bash
2016-08-29 00:13:48 +00:00
$ 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
2016-06-18 06:57:59 +00:00
$ docker-compose up -d
2016-08-27 11:44:32 +00:00
$ docker-compose exec registry sh
2016-06-18 06:57:59 +00:00
>>> htpasswd -Bbn username password >> /auth/htpasswd
2016-08-27 11:44:32 +00:00
>>> cat >> /etc/docker/registry/config.yml
proxy:
remoteurl: https://registry-1.docker.io
username: username
password: password
^D
2016-06-18 06:57:59 +00:00
>>> exit
2016-08-27 11:44:32 +00:00
$ docker-compose restart
2016-08-29 00:13:48 +00:00
```
## Client Setup
```bash
$ scp registry.easypi.info:fig/registry/certs/domain.crt \
/etc/docker/certs.d/registry.easypi.info:5000/ca.crt
$ systemctl edit docker
# /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --registry-mirror https://registry.easypi.info:5000
$ systemctl daemon-reload
$ systemctl restart docker
2016-06-18 06:57:59 +00:00
$ docker pull alpine
2016-06-20 13:33:42 +00:00
$ docker tag alpine registry.easypi.info:5000/alpine
2016-06-18 06:57:59 +00:00
$ docker login -u username -p password easypi.info:5000
2016-06-20 13:33:42 +00:00
$ docker push registry.easypi.info:5000/alpine
2016-08-29 00:13:48 +00:00
$ docker rmi registry.easypi.info:5000/alpine
2016-06-20 13:33:42 +00:00
$ docker pull registry.easypi.info:5000/alpine
2016-08-29 00:13:48 +00:00
$ firefox http://registry.easypi.info:8080
2016-06-18 06:57:59 +00:00
```
2016-08-29 00:13:48 +00:00
> Append `--insecure-registry registry.easypi.info:5000` option to disable TLS.
## Read More
2016-06-20 13:33:42 +00:00
- https://github.com/docker/distribution/blob/master/docs/deploying.md
- https://github.com/docker/distribution/blob/master/docs/insecure.md
- https://serversforhackers.com/tcp-load-balancing-with-nginx-ssl-pass-thru
2016-08-27 11:44:32 +00:00
- https://github.com/docker/distribution/blob/master/docs/recipes/mirror.md
2016-06-20 13:33:42 +00:00
2016-06-18 06:57:59 +00:00
[1]: https://github.com/docker/distribution