1- # [ Postgres 17.2 ] ( https://github.com/livingdocsIO/dockerfile-postgres ) [ ![ ] ( https://img.shields.io/badge/docker-livingdocs%2Fpostgres-blue )] ( https://hub.docker.com/r/livingdocs/postgres )
1+ # [ Postgres 18.0 ] ( https://github.com/livingdocsIO/dockerfile-postgres ) [ ![ ] ( https://img.shields.io/badge/docker-livingdocs%2Fpostgres-blue )] ( https://hub.docker.com/r/livingdocs/postgres )
22
33- Based on Debian
44- Includes ` postgres-contrib ` , enables the extensions ` pg_stat_statements ` by default
55- Includes [ wal-g] ( https://github.com/wal-g/wal-g ) for WAL archiving and shipping
6- - Includes [ pg_auto_failover] ( https://github.com/citusdata/pg_auto_failover ) for automatic failover
76- Runs as postgres user with uid (1000), gid (1000)
87- Does not try to fix permissions during boot to support a fast startup
98- Does not have Dockerfile VOLUME declarations and therefore no issues with pg_upgrade --link
1312
1413``` bash
1514# Secured with a password, by default the image is secure
16- docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql -e POSTGRES_PASSWORD=somepassword livingdocs/postgres:17.2
15+ docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql -e POSTGRES_PASSWORD=somepassword livingdocs/postgres:18.0
1716```
1817
1918## Upgrade an existing postgres container
@@ -24,42 +23,42 @@ docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livin
2423
2524# First stop it, then run the upgrade image
2625docker stop postgres
27- docker run --rm -v postgres:/var/lib/postgresql livingdocs/postgres:17.2 -upgrade
26+ docker run --rm -v postgres:/var/lib/postgresql -v postgres-socket:/var/run/postgresql livingdocs/postgres:18.0 -upgrade
2827
2928# After it succeeds, you can run the new image and mount the existing volume
30- docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livingdocs/postgres:17.2
29+ docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql -v postgres-socket:/var/run/postgresql livingdocs/postgres:18.0
3130```
3231
3332## To build this image manually
3433
3534``` bash
36- docker build -t livingdocs/postgres:17.2 .
35+ docker build -t livingdocs/postgres:18.0 .
3736```
3837
3938With buildx on docker
4039``` bash
4140# To build and push the multi-arch manifest to docker hub
42- docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:17.2 --push .
41+ docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:18.0 --push .
4342
44- docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:17.2 -upgrade --push -f Dockerfile.upgrade .
43+ docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:18.0 -upgrade --push -f Dockerfile.upgrade .
4544```
4645
4746With nerdctl on lima/containerd
4847``` bash
49- nerdctl build --platform=amd64,arm64 -t livingdocs/postgres:17.2 .
50- nerdctl build --platform=amd64,arm64 -t livingdocs/postgres:17.2 -upgrade -f Dockerfile.upgrade .
48+ nerdctl build --platform=amd64,arm64 -t livingdocs/postgres:18.0 .
49+ nerdctl build --platform=amd64,arm64 -t livingdocs/postgres:18.0 -upgrade -f Dockerfile.upgrade .
5150
52- lima nerdctl push --all-platforms livingdocs/postgres:17.2
53- lima nerdctl push --all-platforms livingdocs/postgres:17.2 -upgrade
51+ lima nerdctl push --all-platforms livingdocs/postgres:18.0
52+ lima nerdctl push --all-platforms livingdocs/postgres:18.0 -upgrade
5453```
5554
5655## Set up streaming replication
5756
5857### Simple setup
5958``` bash
6059# Create the containers
61- docker run -d -p 5433:5432 --name postgres-1 livingdocs/postgres:17.2
62- docker run -d -p 5434:5432 --name postgres-2 livingdocs/postgres:17.2 standby -d " host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"
60+ docker run -d -p 5433:5432 --name postgres-1 livingdocs/postgres:18.0
61+ docker run -d -p 5434:5432 --name postgres-2 livingdocs/postgres:18.0 standby -d " host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"
6362
6463# Test the replication
6564docker exec postgres-1 psql -c " CREATE TABLE hello (value text); INSERT INTO hello(value) VALUES('world');"
@@ -77,7 +76,7 @@ docker exec postgres-2 psql -c "SELECT * FROM hello;"
7776docker network create local
7877
7978# First create the database primary
80- docker run -d -p 5433:5432 --name postgres-1 --network=local --network-alias=postgres -e POSTGRES_HOST_AUTH_METHOD=md5 livingdocs/postgres:17.2
79+ docker run -d -p 5433:5432 --name postgres-1 --network=local --network-alias=postgres -e POSTGRES_HOST_AUTH_METHOD=md5 livingdocs/postgres:18.0
8180
8281# Create the users on database intialization
8382# You could also mount an sql or script into /var/lib/postgresql/initdb.d during cluster startup to execute the script automatically.
@@ -86,8 +85,8 @@ docker exec postgres-1 psql -c "CREATE USER replication REPLICATION LOGIN ENCRYP
8685
8786# The launch the replicas
8887export DB_URL=" host=postgres port=5432 user=replication password=some-replication-password target_session_attrs=read-write"
89- docker run -d -p 5434:5432 --name postgres-2 --network=local --network-alias=postgres livingdocs/postgres:17.2 standby -d $DB_URL
90- docker run -d -p 5435:5432 --name postgres-3 --network=local --network-alias=postgres livingdocs/postgres:17.2 standby -d $DB_URL
88+ docker run -d -p 5434:5432 --name postgres-2 --network=local --network-alias=postgres livingdocs/postgres:18.0 standby -d $DB_URL
89+ docker run -d -p 5435:5432 --name postgres-3 --network=local --network-alias=postgres livingdocs/postgres:18.0 standby -d $DB_URL
9190
9291# Test the replication
9392docker exec postgres-1 psql -c " CREATE TABLE hello (value text); INSERT INTO hello(value) VALUES('hello');"
0 commit comments