All Courses
Docker Private registry

The docker private registry is a stateless, highly extensible server-side application. Distribute the Docker image. The registry is open source and is under an authorized Apache license.

USES

You need to use the registry if:

  1. Tightly control the storage location of images
  2. Completely own the image delivery pipeline
  3. Tightly integrate image storage and delivery into custom development Workflow

Requirements

Registration will start from here. –restart = always means (if you use the registry as part of your persistent infrastructure, you should set it to restart automatically when Docker restarts or exits).

$ docker run -d -p 5000:5000 --restart=always --name registry registry:2
Docker Private registry - Pull complete

Check the registry container or do not use the following command:

$ docker ps
Docker Private registry - tcp registry

Pull (or build) some images from the hub

$ docker pull ubuntu

Tag the image to point to the registry

$ docker image tag ubuntu localhost:5000/my-ubuntu

Put it in your private registry

$ docker push localhost:5000/my-ubuntu

Try deleting the local image and pulling it from the local repository.

$ docker image remove ubuntu
$ docker image remove localhost:5000/my-ubuntu
$ docker pull localhost:5000/my-ubuntu

Stop registration here and delete all data

$ docker container stop registry && docker container rm -v registry

Reference:

https://docs.docker.com/registry/deploying/

Customize the storage location

By default, registry data is stored on the host file system as a Docker volume. If you want to save the contents of the registry to a specific location on the host file system (for example, B. If you have the SSD or SAN mounted in a specific directory, you can choose to use bind-mount instead. Depends on the file system layout of the Docker host, but improves performance in many situations. The following example binds the /mnt/registry host directory to the registry container at the /var/lib/registry/.

$ docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v /mnt/registry:/var/lib/registry \
registry:2

Gets a list of images in the private registry.

$ curl -X GET http://localhost:5000/v2/_catalog

If desired, all tags form a particular image.

curl -X GET http://localhost:5000/v2/my-ubuntu/tags/list

If you want to remove the tag first, you need to get the catalog and the tag and then use the following command:

curl -v –silent -H “Accept: application/vnd.docker.distribution.manifest.v2+json” -X GET
http://localhost:5000/v2/my-ubuntu/manifests/latest 2>&1 | grep Docker-Content-Digest | awk ‘{print
($3)}’

Docker Private registry - print

Execute the following command with the manifest value specified:

curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X
DELETE http://127.0.0.1:5000/v2/my-ubuntu/manifests/
sha256:f2557f94cac1cc4509d0483cb6e302da841ecd6f82eb2e91dc7ba6cfd0c580ab

if you face the below error

Docker Private registry - registry storage

If you want to delete the image, you need to set the called environment variable
REGISTRY_STORAGE_DELETE_ENABLED = true

docker run -d -p 5000:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true --restart=always --
name registry registry:2
gmt

Install Jenkins using docker

$ docker run -p 8080:8080 -p 50000:50000 jenkins
This will store the workspace in /var/jenkins_home. All Jenkins data lives in there - including
plugins and configuration. You will probably want to make that a persistent volume

(recommended):

docker run -d -p 8080:8080 -p 50000:50000 -u root  v /Jenkins_home:/var/jenkins_home
jenkins

You can run the build on the master (ready to use), but if you connect a build slave server:
Be sure to map the port: -p 50000: 50000-this is used when connecting slaves Agent.