Skip to content

A local docker registry cache to lower bandwidth required when install several similar container.

License

Notifications You must be signed in to change notification settings

Svtter/docker-compose-registry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker registry cache

License

Oyster registry

Concept

  • Create a Docker registry cache for local network to speed up docker image download and keep a lower bandwidth.
  • Use docker-compose.

Cache (server) setup

Clone this repo:

$ git clone [email protected]:maxmasetti/docker-compose-registry.git registry

or

$ git clone https://github.com/maxmasetti/docker-compose-registry.git registry

and start it up:

$ cd registry
$ docker-compose up

It's done.

Optionally

Map the data folder to a better place: edit docker-compose.yml row

    volumes:
      - ./data:/var/lib/registry:rw

and modify ./data to fit your needs.

Client setup

Modify or create the file /etc/docker/daemon.json and add the local mirror setting pointing to your server on port 5000:

{
  "registry-mirrors": ["http://<my-docker-mirror-host-ip>:5000"]
}

Then restart docker daemon:

$ service docker stop
$ service docker sart

Test

Verify that everything is working correctly running a new image on the client while watching server's log. First check if the required image is locally available,

$ docker image ls -a
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
...
hello-world                   latest              48b5124b2768        14 months ago       1.84kB
...

and remove it (hello-world in this case) if exists:

$ docker image rm 48b5124b2768

Verify your registry cache is empty. From the client query the server trhough the exposed API:

$ curl http://<my-docker-mirror-host-ip>:5000/v2/_catalog
# outputs -> {"repositories":[]}

In the client, run hello-world:

$ docker run hello-world

and verify it is present on your registry cache (server):

$ curl http://<my-docker-mirror-host-ip>:5000/v2/_catalog
# outputs -> {"repositories":["library/busybox"]}

In the server log some line should pass showing desired activity too. The images downloaded will be stored in the server data folder and listed in the nested folder data/docker/registry/v2/repositories/library/.

TBD

Secure the registry implementing ssl (https) on port 5000.

Some description

Docker-compose file (server)

docker-compose.yml:

version: '3.3'

services:
  registry:
    restart: always
    image: registry:latest
    ports:
      - 5000:5000
    volumes:
      - ./config/default/config.yml:/etc/docker/registry/config.yml:ro
      - ./data:/var/lib/registry:rw
  #environment:
    #- "STANDALONE=true"
    #- "MIRROR_SOURCE=https://registry-1.docker.io"
    #- "MIRROR_SOURCE_INDEX=https://index.docker.io"

Registry configuration (server)

/etc/docker/registry/config.yml:

version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
proxy:
  remoteurl: https://registry-1.docker.io
  # username: [username]
  # password: [password]

Client side

/etc/docker/daemon.json:

{
  "registry-mirrors": ["http://<my-docker-mirror-host-ip>:5000/"]
}

On macOS, open preferences of Docker application from the menu bar, then go to Daemon tab -> Advanced and insert the previous row. Apply and restart. Test if it works as expected.

macOS registry setup

Documentation

Works this one is based on

;)

About

A local docker registry cache to lower bandwidth required when install several similar container.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published