”;
Description
Container registry is a storage and content delivery system, which stores their Docker (it is database of predefined images used to run applications.) images.
Deploying the Registry
You can deploy the registry by using the below commands −
Step 1 − First, login to your GitLab server using SSH (Secure Shell).
Step 2 − Now start the registry container by using below command −
$ docker run -d -p 5000:5000 --restart = always --name registry registry:2
The -p 5000:5000 specifies first part as host port and second part as port within the container. The –restart = always flag restarts the registry automatically when Docker restarts. The registry:2 is defined as an image.
Step 3 − Now, pull the image from Docker hub to your registry −
$ docker pull ubuntu:16.04
The above command pulls the ubuntu:16.04 image from Docker Hub.
Step 4 − Next, tag the image to point your registry −
$ docker tag ubuntu:16.04 localhost:5000/my-ubuntu
Here, we are tagging the localhost:5000/my-ubuntu image for an existing ubuntu:16.04 image.
Step 5 − Push the image to local registry which is executing at localhost:5000.
$ docker push localhost:5000/my-ubuntu
Step 6 − Now remove the cached (ubuntu:16.04 and localhost:5000/my-ubuntu) images from the registry −
$ docker image remove ubuntu:16.04 $ docker image remove localhost:5000/my-ubuntu
Step 7 − Pull back the localhost:5000/my-ubuntu image from local registry −
$ docker pull localhost:5000/my-ubuntu
Step 8 − Now stop the registry and remove the data −
$ docker container stop registry && docker container rm -v registry
”;