This file is telling Docker Compose to run a container using the paintedfox/postgresql image and to attach the container’s /data folder to /my/local/filesystem/some-dir folder in our local filesystem. It is also telling the container to export the port 5432.

  container_name: my_psql_container
  restart: always
  image: paintedfox/postgresql
    - /my/local/filesystem/some-dir:/data
    - ""

Note: don’t use the -d option the first time you start the container so you can get the username and password created during the postgresql db initialization.

Starting the container:

docker-compose up -d

Stoping the container:

docker-compose stop