Skip to content

Latest commit

 

History

History
89 lines (71 loc) · 4.02 KB

LAB05-DockerLocalRegistry.md

File metadata and controls

89 lines (71 loc) · 4.02 KB

LAB-05: Running Docker Free Local Registry, Tagging Container, Pushing to Local Registry, Pulling From Local Registry

This scenario shows how to run Docker local free registry, tag container, push into the local registry and pull from the registry.

Steps

  • Pull 'Registry' image from Docker Hub:
docker image pull registry

image

  • Run container using 'Registry' image: (-p: port binding [hostPort]:[containerPort], -d: detach mode (running background), -e: change environment variables status)
docker container run -d -p 5000:5000 --restart always --name localregistry -e REGISTRY_STORAGE_DELETE_ENABLED=true registry

image

  • Run registry container with binding mount (-v) and without getting error 500 (REGISTRY_VALIDATION_DISABLED=true):
docker run -d -p 5000:5000 --restart=always --name registry -v /home/docker_registry:/var/lib/registry -e REGISTRY_STORAGE_DELETE_ENABLED=true -e REGISTRY_VALIDATION_DISABLED=true -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 registry:2
  • Open a browser: (localregistry runs on 127.0.0.1:5000)
http://127.0.0.1:5000/v2/_catalog

image

  • To push the image to localregistry, firstly change the name of the image using 'tag', add '127.0.0.1:5000/' as a prefix of the image to push localregistry:
docker image tag [sourceImageName] [targetImageName]
docker image tag alpine 127.0.0.1:5000/alpine:latest (pushing alpine image)
docker image push 127.0.0.1:5000/alpine:latest
docker image tag busybox 127.0.0.1:5000/busybox:latest
docker image push 127.0.0.1:5000/busybox:latest

image

  • Refresh the browser to see latest status:

image

  • To download from localregistry:
docker image pull [imageName]
docker image pull 127.0.0.1:5000/busybox:latest

image

docker exec -it localregistry rm -rf /var/lib/registry/docker/registry/v2/repositories/alpine
docker exec -it localregistry rm -rf /var/lib/registry/docker/registry/v2/repositories/busybox

image

  • After deletion, as expected, when trying pulling image from localregistry, it is not found:

image

image

  • Docker registy stores both Windows and Linux Container at the same time:
docker run -d -p 5000:5000 --restart=always --name registry -v /home/docker_registry:/var/lib/registry -e REGISTRY_STORAGE_DELETE_ENABLED=true -e REGISTRY_VALIDATION_DISABLED=true -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 registry:2
  • Switch Docker Desktop to Windows Container
  • Please add "IP:5000" in your Docker Desktop (Settings>Docker Engine>"insecure-registries")
  • Tagging Image:
docker tag mcr.microsoft.com/windows/nanoserver:1909 {IPofRegistryServer}:5000/windows-nanoserver
  • Pushing Image:
docker push {IPofRegistryServer}:5000/windows-nanoserver
  • Browsing: IP:5000/v2/_catalog

image