Skip to content

hochschule-pforzheim/docker-database

 
 

Repository files navigation

logo DockerDatabase

Welcome to the DockerDatabase! The project is dedicated to deliver free database models defined in SQL and stored in PostgreSQL database systems. It is called DockerDatabase because a Docker build file is included in order to deliver database models and data as part of docker images.

A Docker image is also used in classroom environment at Hochschule Pforzheim. The main database utilized in this context is the Mondial database. Students may use this project to setup their own environment.

Publish Docker Image

Database Models

This project delivers different database models. All of them are implemented as PostgreSQL schema including corresponding data. Besides that all models also provide SQL instructions to delete (drop) the schema. Currently the project includes these schemas:

  • Mondial (public)
  • Warehouse (warehouse)

Get Ready

In order to use these schemas within a docker container, you'll have to build a proper image first. Currently the Mondial schema is integrated by default. For other schemas you have to modify the Dockerfile or interact with the Docker container directly.

Environment Variables

The Dockerfile comes with several environment variables which you may modify. Since our image relies on the official docker image of PostgreSQL, the mandatory admin password for postgres is included in these default presets as well.

The following environment variables are pre-defined:

Variable Description Default Value Source
POSTGRES_USER postgres superuser (admin) postgres PostgreSQL
POSTGRES_PASSWORD password for postgres superuser admin PostgreSQL, preset by this image definition
MONDIALDB the postgres name of the mondial database mondial defined by image definition
MONDIALUSER the username for accessing the MONDIALDB database mondial defined by image definition
USERPASSWORD the password for the MONDIALUSER mondial! defined by image definition

Build and run DockerDatabase with Mondial

In root directory of this project. Build the image by calling:

foo@bar:~$ docker build -t ngmondial .

Run your image

foo@bar:~$ docker run --name ngmondial -e "POSTGRES_PASSWORD=admin" -p 5432:5432 -d ngmondial

Publishing ports as defined by -p 5432:5432 is optional and only needed in case you want to have direct access to the database from your host.

In case you plan to store postgres data in a host directory (e.g. for backup of changes), you can add a volume option to your run command. Such as: -v </path/to/host/directory>:/var/lib/postgresql/data/.

About

Database examples with Docker and PostgreSQL

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PLpgSQL 99.4%
  • Other 0.6%