This post is largely the result of:
- Jonathan Adams (@RebelActuary) and his wonderful presentation over docker
- Alvise Susmel (@alvisesus) and his blog post about using Postgres and Docker
Thank you both.
Rather than spending the time installing and configuring a database locally, start coding faster with docker-compose. Start a Postgres server with
docker-compose up -d. Stop the server with
# docker-compose.yml version: "3" services: db: image: postgres:11-alpine container_name: "postgres" ports: - "5432:5432" volumes: - postgres-dev:/var/lib/postgresql/data environment: - POSTGRES_PASSWORD=postgres volumes: postgres-dev:
This file contains the settings outlined in the Postgres and Docker post.
- image: this selects the version of Postgres to run,
- container_name: the name of the container,
- ports: the port mapping between the local machine and container,
- volumes: mounts the volume to the container to persist the data between runs,
- environment: sets the Postgres password as an environment variable
Hopefully this helps speed up your development speed!