📜 ⬆️ ⬇️

Quick launch and use of your open docker-registry

Docker is software for automating the deployment and management of applications in a virtualization environment ( see Wikipedia ).
Detailed installation instructions are on the official site: https://docs.docker.com/engine/installation/

If you are reading this article, you are probably already familiar with the docker and are ready to take the next step - to raise your own register for convenient delivery of applications to the production server.

When I started to make a new project - I decided to try using docker. It turned out four containers that need to somehow be delivered to the server. Then follows the story of what I got from this.
')
What is available at the entrance:


Docker Register is a repository with versioned docker images.
It is convenient to use the register for delivering the application to the server:

  1. on the work computer we collect the image and send it to the register
  2. on the virtual server we take away the image from the register and run

Docker has an official registry as a service: https://hub.docker.com
There you can place an unlimited number of public images and only one private one. More private images can be added for a fee.

Another way to use the register is to raise your own.
Docker provides an official image with the registry server , in addition there is documentation with instructions for launching .

The docker registry is able to work with both http and https. When using a secure connection, it is also possible to authorize individual users. But you need a certificate that you can buy only for a domain name. I never managed to get the self-signed certificate to work (I read on the Internet that there are problems with this). In view of the fact that I do not have a domain name, we will consider an open register with access via http . This means that if someone finds out the address of your register - he will be able to use it freely.

Running register


Setup on the server

The register is a docker-container, which is started with one command:

› docker run -d -p 5000:5000 --restart=always --name registry registry:2 

This is done, but in order for the docker client on this server to access the register via an open connection without authorization, you need to add a line to the / etc / default / docker configuration file:

 DOCKER_OPTS="$DOCKER_OPTS --insecure-registry <ip- >:5000" 

After that, you need to restart the docker:

 › service docker restart 

Settings on the client

My computer uses the VirtualBox virtualization system for the docker to work, in which boot2docker is started (the minimum Linux image with the docker), which in turn works with containers. There may be several virtual machines running under VirtualBox on a computer; the docker-machine is used to manage them.

In order to be able to access the register via an open connection without authorization, you need to add an option to the configuration file that lies inside the virtual machine under which the containers work.

Let's see the list of virtual machines:

 › docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1 

Connect to our virtual machine:

 › docker-machine ssh default 

It contains the file / var / lib / boot2docker / profile , in which there is such a fragment:

 EXTRA_ARGS=' --label provider=virtualbox ' 

Open it for editing with sudo to make it like this:

 EXTRA_ARGS=' --label provider=virtualbox --insecure-registry <ip- >:5000 ' 

Register use


Formation and sending of an image from the working computer

Imagine that you already have a Dockerfile in the current directory and we can simply compile a new image with the name my-image :

 › docker build -t my-image . 

Now you can add an image tag and send it to the register:

 › docker tag my-image <ip- >:5000/my-image:latest › docker push <ip- >:5000/my-image:latest 

Getting the image on the server

Now the image is in the register, we can get it on the server and run:

 › docker pull <ip- >:5000/my-image:latest › docker run -d <ip- >:5000/my-image 

Conclusion


So, we raised our own open register for storing docker-images and looked at an example of sending-receiving an image with it.
I hope that this will be useful to someone, because I really lacked such a guide.

Source: https://habr.com/ru/post/279659/


All Articles