Aim

In this post we will be hosting our own docker registry using docker compose

Prerequisite

  • Docker must be installed on your machine
  • Docker compose must be installed on your machine

Step 1 : Create a yaml file

touch docker-compose.yml

Step 2 : Put the following components in the above file

version: "3"
services:
  docker-registry:
    image: registry:2
    container_name: docker-registry
    ports:
    - 5000:5000
    restart: always
    volumes:
    - ./docker-registry:/var/lib/registry

  docker-registry-ui:
    image: konradkleine/docker-registry-frontend:v2
    container_name: docker-registry-ui
    ports:
    - 8080:80
    environment:
      ENV_DOCKER_REGISTRY_HOST: docker-registry
      ENV_DOCKER_REGISTRY_PORT: 5000

Step 3 : Start the service

  • You can start the service in foreground mode using
docker-compose -f docker-compose.yml up
  • If you want to start the service in background mode then you can use the below command
docker-compose -f docker-compose.yml up -d

Update you host file for docker client machine

  • You need to go to the machine where you will be creating docker images
  • Open the host file using
vim /etc/hosts
  • Put your docker registry hostname in /etc/hosts file
<ip-address-of-docker-registry-machine>  selftuts.local.com
  • You can put any name in place of selftuts.local.com

Updating docker client for insecure Auth

  • This process is followed on the machine from where you will be connecting to the docker registry
  • We have created an insecure docker registry so we need to do the following settings
  • Open the below file in your docker client machine
vim /etc/docker/daemon.json
  • Put the following entry int that file
{
    "insecure-registries" : ["selftuts.local.com:5000"]
}

Happy Coding

0 0 vote
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x