Docker installation

Figure 648. Preconditions Slide presentation
  • A working environment:

  • Sufficient disk space related mainly to your database(es) size(es).

Figure 649. Starting Docker container Slide presentation
docker run --restart always  \
  --name postgres-latest  \
  -p 5432:5432  \ 
  -e POSTGRES_PASSWORD=mySecretPassword  \
  -d \ 
  -v /home/goik/var/lib/postgresql/data:/var/lib/postgresql/data  
  postgres  \


Run container and restart automatically.

Your container's local name i.e. when listing containers using docker container ls.

Bind your docker host system's port 5432 to the container's port. Database connections to i.e. localhost:5432 will be forwarded to the database server running inside your container.

Image specific environment variable. See Environment Variables section.

Running container in detached rather than foreground mode.

Optional: Mounting a directory from your Docker host system into the container. Database files will then be stored outside the container.

The Docker hub's image name.

The running container's UUID long identifier value.

Figure 650. Database server post configuration Slide presentation
docker exec -it postgres-latest bash 

# su - postgres 

$ createuser hdmuser 
$ createdb --owner hdmuser hdm 
$ psql 
psql (12.3 (Debian 12.3-1.pgdg100+1))
Type "help" for help.

postgres=# alter role hdmuser WITH PASSWORD 'XYZ'; 
postgres=# exit

Enter your Docker container.

Become postgres system user.

Create new Postgres database user.

Create new database hdm owned by user hdmuser.

Connect to database server.

Set password XYZ for database user hdmuser.