Private Docker registry
How to run your own private Docker registry
With Docker on the rise the need for running your own Docker containers rises as wel. With Hipex Docker support this is now a piece of cake.
In this example we will be running Docker Registry.
Installation
We will be using the Hipex CLI docker commands to run the container. For the rest of this tutorial we assume you are familiar with the docker basics.
Step 1
Create your Docker configuration file in ~/domains/docker-registry.example.com/registry/docker-compose.yml
.
version: '3.2'
services:
registry:
image: registry:2.7
volumes:
- registry-data:/registry_data
ports:
- 15000:5000
volumes:
registry-data:
Now the service can be started using docker:compose:up
.
cd ~/domains/example.com/registry/
hipex docker:compose:up --detach
Step 2
Now we setup authentication and configure Nginx to proxy requests to our new registry. More detail about basic auth can be found here.
~/domains/docker-registry.example.com/var/etc/port-443/proxy.nginx.conf
location ~* ^\/.* {
proxy_pass http://127.0.0.1:15000;
# Default proxy settings
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
send_timeout 6000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Step 3
The registry is now usable from your local machine at your docker-registry.example.com
with the default docker commands.
docker login <username>
docker push docker-registry.example.com/some-image:latest