Setting up private docker registry and postgresql database with `docker compose` - adigunhammedolalekan/appear GitHub Wiki
docker-compose
Setting up private docker registry and postgresql database with appear
depends on docker registry to push and pull images for it to be available for deployment on K8s. The following steps set up both docker registry
and postgresql
database using docker-compose
on Ubuntu 18.04
, this setup should work for other versions of Ubuntu and other Unix systems.
Requirements
This setup requires the following packages to be installed.
- Docker
- docker-compose
- git
The steps
- create directories to mount into the containers(docker-registry, postgresql)
$ mkdir -p /mnt/database
# create postgresql data directory on the host system$ mkdir -p /mnt/registry/data
# create a directory for docker-registry to store images data$ mkdir -p /mnt/registry/auth && touch /mnt/registry/auth/registry.password
# create a file for docker-registry to store usernames and passwords for authentication
- download
docker-compose
file template and edit to suit your need.
git clone https://github.com/adigunhammedolalekan/appear-compose
cd appear-compose && nano docker-compose.yml
You should see the following:
version: "3.1"
services:
docker-registry:
restart: always
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry
REGISTRY_AUTH_HTPASSWD_PATH: /mnt/registry/auth/registry.password
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /mnt/registry/data
volumes:
- **{docker_registry_data_dir_on_host}**:/mnt/registry/data
- **{docker_registry_password_auth_dir_on_host}**:/mnt/registry/auth/registry.password
pgdatabase:
image: postgres:10.4
container_name: pgdatabase
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: man
POSTGRES_DB: appear
PGDATA: /mnt/database
volumes:
- **{your_database_path_on_host}**:/mnt/database
ports:
- "5432:5432"
Note the emboldened texts {text} and change them accordingly to the directories you created above. Now, we are set!
$ docker-compose up
should start both postgresql(localhost:5432) and docker-registry(localhost:5000)
registry.password
Adding a username and password to - Install
htpasswd
$ sudo apt install apache2-utils
- Navigate to
/mnt/registry/auth
or anywhere yourregistry.password
is located on the host system.
$ cd /mnt/registry/auth
$ htpasswd -Bc registry.password **username**
# where**username**
is your desired username. You'll be prompted to enter a password, enter the password then pressOk
.
- Restart
docker-compose
$ docker-compose down
# first kill containers$ docker-compose up
# restart containers
postgresql is running on :5432 registry is running on :5000