Linux/Docker/Registry: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
ports: | ports: | ||
- "5000:5000" | - "5000:5000" | ||
environment: | |||
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data | |||
volumes: | |||
- /srv/docker-data/registry:/data | |||
</pre> | </pre> | ||
Line 13: | Line 17: | ||
docker-compose up -d | docker-compose up -d | ||
</pre> | </pre> | ||
== Put example image in registry == | |||
<pre> | |||
docker pull alpine | |||
docker tag alpine vm-docker:5000/my-alpine | |||
docker push vm-docker:5000/my-alpine | |||
</pre> | |||
== On testing client disable secure registry == | |||
* /etc/docker/daemon.json | |||
<pre> | |||
{ | |||
"insecure-registries":["vm-docker:5000"] | |||
} | |||
</pre> | |||
== Load image from registry == | |||
<pre> | |||
docker pull vm-docker:5000/my-alpine | |||
test: | |||
docker run -it vm-docker:5000/my-alpine sh | |||
</pre> | |||
== Add authentication to registry server == | |||
<pre> | |||
sudo apt install apache2-utils | |||
mkdir /srv/docker-data/registry/auth | |||
cd /srv/docker-data/registry/auth | |||
htpasswd -Bc registry.password testusername | |||
</pre> | |||
* docker-compose.yml | |||
<pre> | |||
version: '3' | |||
services: | |||
registry: | |||
image: registry:2 | |||
ports: | |||
- "5000:5000" | |||
environment: | |||
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data | |||
REGISTRY_AUTH: htpasswd | |||
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm | |||
REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.password | |||
volumes: | |||
- /srv/docker-data/registry:/data | |||
- /srv/docker-data/auth:/auth | |||
</pre> | |||
* test | |||
<pre> | |||
docker login vm-docker:5000 | |||
</pre> | |||
= Pull-through caching for whole LAN = | |||
* on clients: /etc/docker/daemon.json: | |||
<pre> | |||
{ | |||
"registry-mirrors": ["http://homeserver:5000"], | |||
"insecure-registries": [ "homeserver:5000" ] | |||
} | |||
</pre> | |||
[[Category:Linux/Docker]] | [[Category:Linux/Docker]] | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 18:11, 12 December 2021
Example docker-compose.yml
version: '3' services: registry: image: registry:2 ports: - "5000:5000" environment: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data volumes: - /srv/docker-data/registry:/data
docker-compose up -d
Put example image in registry
docker pull alpine docker tag alpine vm-docker:5000/my-alpine docker push vm-docker:5000/my-alpine
On testing client disable secure registry
- /etc/docker/daemon.json
{ "insecure-registries":["vm-docker:5000"] }
Load image from registry
docker pull vm-docker:5000/my-alpine test: docker run -it vm-docker:5000/my-alpine sh
Add authentication to registry server
sudo apt install apache2-utils mkdir /srv/docker-data/registry/auth cd /srv/docker-data/registry/auth htpasswd -Bc registry.password testusername
- docker-compose.yml
version: '3' services: registry: image: registry:2 ports: - "5000:5000" environment: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data REGISTRY_AUTH: htpasswd REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.password volumes: - /srv/docker-data/registry:/data - /srv/docker-data/auth:/auth
- test
docker login vm-docker:5000
Pull-through caching for whole LAN
- on clients: /etc/docker/daemon.json:
{ "registry-mirrors": ["http://homeserver:5000"], "insecure-registries": [ "homeserver:5000" ] }