diff --git a/README.md b/README.md index 8116e8a..1f85f73 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1394 TILs and counting..._ +_1395 TILs and counting..._ --- @@ -194,6 +194,7 @@ _1394 TILs and counting..._ ### Docker - [Configure Different Host And Container Ports](docker/configure-different-host-and-container-ports.md) +- [Run A Basic PostgreSQL Server In Docker](docker/run-a-basic-postgresql-server-in-docker.md) ### Elixir diff --git a/docker/run-a-basic-postgresql-server-in-docker.md b/docker/run-a-basic-postgresql-server-in-docker.md new file mode 100644 index 0000000..843ea0e --- /dev/null +++ b/docker/run-a-basic-postgresql-server-in-docker.md @@ -0,0 +1,36 @@ +# Run A Basic PostgreSQL Server In Docker + +Here is a basic `docker-compose.yml` file for spinning up a Docker container +that runs a PostgreSQL server on port 5432. This is what I use to create a +locally-running PostgreSQL server that lives inside a docker container. + +```yaml +version: "3.7" +services: + postgres: + image: postgres:latest + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=postgres + ports: + - "5432:5432" + volumes: + - ./postgres-data:/var/lib/postgresql/data +``` + +To create the docker container and start it up, run the following command from +the same directory where you put this file: + +```bash +$ docker compose up +``` + +This command knows to look for the `docker-compose.yml` file though you can +always be explicit about the file with the `-f` option. + +This configuration points at `postgres:latest` which currently is `16.1`. To +run a different major version, you can change the `image` to something like +`postgres:15`. See [Docker Hub](https://hub.docker.com/_/postgres) for more +options.