docker-compose.yml for PostgreSQL

Last Updated on

This post provides a basic docker-compose.yml to create a PostgreSQL container with initial user account with password.

Tested with:

  1. Docker for Windows
  2. PostgreSQL 12
  3. Windows 10


A docker-compose.yml is just text file. The YAML below can be used to create and run a Docker container that has a PostgreSQL in it with valid user account.

How to use

1. Copy docker-compose.yml to some folder

2. Open a Windows Command Line Prompt in that path

3. Run some commands

3.1 Pull the image from Docker Hub to the local machine.


3.2 Start the PostgreSQL container

Karl San Gabriel

Karl San Gabriel

Professional Software Developer