How to set up a local docker registry on a Linux server?
The story began when my organization doesn’t allow using any cloud service providers like AWS or Azure. Therefore I spent time researching and found a solution to host our own local registry on-premise servers.
What do I mean by docker registry? a registry is a storage that keeps your docker images remotely so that you can pull and make use when you want in the future. It benefits me a lot when it comes to a local network. I can get an image ready in a flash.
In this article, I am going to show how to install it using docker-compose, but before you get started, make sure that you have docker, and docker-compose installed on your local server. If you have not, please refer to the link below and install it.
https://docs.docker.com/engine/install/
https://docs.docker.com/compose/install/
First, on your Linux machine run this command.
mkdir docker-registry
Go into the newly created directory and Create docker-compose.yml
touch docker-compose.yml
Open the docker-compose.yml file using your preferred text editors can be nano, vim …etc. Then, paste the code below to it.
version: '3.8'
services:
registry:
container_name: docker_registry
image: registry:latest
ports:
- "5000:5000"
restart: always
volumes:
- ./registry:/var/lib/registry
In this case, your registry will be running on port 5000 with the data directory that is being mounted to the folder registry.
Finally, let’s up and running your application.
docker compose up -d
Now after the registry has been up, you can try pushing your image to your registry. To do that, you need to tag your image in the following format.
[server-ip]:[registry-port]/[image-name]:[tag-version]
10.80.80.148:5000/tomcat:0.0.1
Thank you for reading.