Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Sometimes, you might need to override the default commands (`CMD`) or entry poin
```yaml
services:
postgres:
image: postgres
image: postgres:18
entrypoint: ["docker-entrypoint.sh", "postgres"]
command: ["-h", "localhost", "-p", "5432"]
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Volumes have their own lifecycle beyond that of containers and can grow quite la

## Try it out

In this guide, youll practice creating and using volumes to persist data created by a Postgres container. When the database runs, it stores files into the `/var/lib/postgresql/data` directory. By attaching the volume here, you will be able to restart the container multiple times while keeping the data.
In this guide, you'll practice creating and using volumes to persist data created by a Postgres container. When the database runs, it stores files into the `/var/lib/postgresql` directory. By attaching the volume here, you will be able to restart the container multiple times while keeping the data.

### Use volumes

Expand All @@ -62,7 +62,7 @@ In this guide, you’ll practice creating and using volumes to persist data crea
2. Start a container using the [Postgres image](https://hub.docker.com/_/postgres) with the following command:

```console
$ docker run --name=db -e POSTGRES_PASSWORD=secret -d -v postgres_data:/var/lib/postgresql/data postgres
$ docker run --name=db -e POSTGRES_PASSWORD=secret -d -v postgres_data:/var/lib/postgresql postgres:18
```

This will start the database in the background, configure it with a password, and attach a volume to the directory PostgreSQL will persist the database files.
Expand Down Expand Up @@ -115,7 +115,7 @@ In this guide, you’ll practice creating and using volumes to persist data crea
8. Start a new container by running the following command, attaching the same volume with the persisted data:

```console
$ docker run --name=new-db -d -v postgres_data:/var/lib/postgresql/data postgres
$ docker run --name=new-db -d -v postgres_data:/var/lib/postgresql postgres:18
```

You might have noticed that the `POSTGRES_PASSWORD` environment variable has been omitted. That’s because that variable is only used when bootstrapping a new database.
Expand Down
2 changes: 1 addition & 1 deletion content/guides/dotnet/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ spec:
value: example
- name: POSTGRES_PASSWORD
value: example
image: postgres
image: postgres:18
name: db
ports:
- containerPort: 5432
Expand Down
12 changes: 6 additions & 6 deletions content/guides/dotnet/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ services:
db:
condition: service_healthy
db:
image: postgres
image: postgres:18
restart: always
user: postgres
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down Expand Up @@ -250,13 +250,13 @@ services:
- action: rebuild
path: .
db:
image: postgres
image: postgres:18
restart: always
user: postgres
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down Expand Up @@ -355,13 +355,13 @@ services:
environment:
- ASPNETCORE_ENVIRONMENT=Development
db:
image: postgres
image: postgres:18
restart: always
user: postgres
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down
4 changes: 2 additions & 2 deletions content/guides/frameworks/laravel/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ services:
- laravel-development

postgres:
image: postgres:16
image: postgres:18
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
- POSTGRES_DB=app
- POSTGRES_USER=laravel
- POSTGRES_PASSWORD=secret
volumes:
- postgres-data-development:/var/lib/postgresql/data
- postgres-data-development:/var/lib/postgresql
networks:
- laravel-development

Expand Down
4 changes: 2 additions & 2 deletions content/guides/frameworks/laravel/production-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ services:
- laravel

postgres:
image: postgres:16
image: postgres:18
restart: unless-stopped
user: postgres
ports:
Expand All @@ -381,7 +381,7 @@ services:
- POSTGRES_USER=${POSTGRES_USERNAME}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres-data-production:/var/lib/postgresql/data
- postgres-data-production:/var/lib/postgresql
networks:
- laravel-production
# Health check for PostgreSQL
Expand Down
4 changes: 2 additions & 2 deletions content/guides/genai-claude-code-mcp/claude-code-mcp-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ services:
- app-net

db:
image: postgres:<tag>
image: postgres:18
environment:
POSTGRES_USER: example
POSTGRES_PASSWORD: example
POSTGRES_DB: appdb
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
ports:
- "5432:5432"
networks:
Expand Down
2 changes: 1 addition & 1 deletion content/guides/golang/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ spec:
value: whatever
- name: POSTGRES_USER
value: postgres
image: postgres
image: postgres:18
name: db
ports:
- containerPort: 5432
Expand Down
4 changes: 2 additions & 2 deletions content/guides/java/containerize.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ services:
# db:
# condition: service_healthy
# db:
# image: postgres
# image: postgres:18
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# - db-data:/var/lib/postgresql
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down
12 changes: 6 additions & 6 deletions content/guides/java/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ services:
environment:
- POSTGRES_URL=jdbc:postgresql://db:5432/petclinic
db:
image: postgres
image: postgres:18
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=petclinic
- POSTGRES_USER=petclinic
Expand Down Expand Up @@ -193,10 +193,10 @@ services:
environment:
- POSTGRES_URL=jdbc:postgresql://db:5432/petclinic
db:
image: postgres
image: postgres:18
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=petclinic
- POSTGRES_USER=petclinic
Expand Down Expand Up @@ -345,10 +345,10 @@ services:
- action: rebuild
path: .
db:
image: postgres
image: postgres:18
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=petclinic
- POSTGRES_USER=petclinic
Expand Down
2 changes: 1 addition & 1 deletion content/guides/nodejs/configure-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:

services:
postgres:
image: postgres:16-alpine
image: postgres:18-alpine
env:
POSTGRES_DB: todoapp_test
POSTGRES_USER: postgres
Expand Down
4 changes: 2 additions & 2 deletions content/guides/nodejs/containerize.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ services:
# PostgreSQL Database Service
# ========================================
db:
image: postgres:16-alpine
image: postgres:18-alpine
container_name: todoapp-db
environment:
POSTGRES_DB: '${POSTGRES_DB:-todoapp}'
POSTGRES_USER: '${POSTGRES_USER:-todoapp}'
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD:-todoapp_password}'
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql
ports:
- '${DB_PORT:-5432}:5432'
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions content/guides/nodejs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ spec:
spec:
containers:
- name: postgres
image: postgres:16-alpine
image: postgres:18-alpine
ports:
- containerPort: 5432
name: postgres
Expand All @@ -134,7 +134,7 @@ spec:
key: postgres-password
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
mountPath: /var/lib/postgresql
livenessProbe:
exec:
command:
Expand Down
8 changes: 4 additions & 4 deletions content/guides/nodejs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ services:
# PostgreSQL Database Service
# ========================================
db:
image: postgres:16-alpine
image: postgres:18-alpine
container_name: todoapp-db
environment:
POSTGRES_DB: '${POSTGRES_DB:-todoapp}'
POSTGRES_USER: '${POSTGRES_USER:-todoapp}'
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD:-todoapp_password}'
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql
ports:
- '${DB_PORT:-5432}:5432'
restart: unless-stopped
Expand Down Expand Up @@ -133,14 +133,14 @@ services:
- todoapp-network

db:
image: postgres:16-alpine
image: postgres:18-alpine
container_name: todoapp-db
environment:
POSTGRES_DB: '${POSTGRES_DB:-todoapp}'
POSTGRES_USER: '${POSTGRES_USER:-todoapp}'
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD:-todoapp_password}'
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql
ports:
- '${DB_PORT:-5432}:5432'
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion content/guides/pgadmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In this guide you will learn how to:
```yaml
services:
postgres:
image: postgres:17.4
image: postgres:18
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
Expand Down
4 changes: 2 additions & 2 deletions content/guides/pre-seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ $ docker container stop postgres

```plaintext
# syntax=docker/dockerfile:1
FROM postgres:latest
FROM postgres:18
COPY seed.sql /docker-entrypoint-initdb.d/
```

Expand All @@ -204,7 +204,7 @@ $ docker container stop postgres
ports:
- "5432:5432"
volumes:
- data_sql:/var/lib/postgresql/data # Persistent data storage
- data_sql:/var/lib/postgresql # Persistent data storage

volumes:
data_sql:
Expand Down
4 changes: 2 additions & 2 deletions content/guides/python/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
spec:
containers:
- name: postgres
image: postgres
image: postgres:18
ports:
- containerPort: 5432
env:
Expand All @@ -56,7 +56,7 @@ spec:
key: POSTGRES_PASSWORD
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
mountPath: /var/lib/postgresql
volumes:
- name: postgres-data
persistentVolumeClaim:
Expand Down
12 changes: 6 additions & 6 deletions content/guides/python/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ You'll need to clone a new repository to get a sample application that includes
# db:
# condition: service_healthy
# db:
# image: postgres
# image: postgres:18
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# - db-data:/var/lib/postgresql
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down Expand Up @@ -358,13 +358,13 @@ services:
secrets:
- db-password
db:
image: postgres
image: postgres:18
restart: always
user: postgres
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down Expand Up @@ -501,13 +501,13 @@ services:
- action: rebuild
path: .
db:
image: postgres
image: postgres:18
restart: always
user: postgres
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
Expand Down
Loading