Skip to content

Commit 598220a

Browse files
chore(deps): update postgres docker tag from 17.6 to v18 (docker-compose.yml) (#13262)
* chore(deps): update postgres docker tag from 17.6 to v18 (docker-compose.yml) * Add upgrade notes --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
1 parent 927e261 commit 598220a

2 files changed

Lines changed: 93 additions & 3 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ services:
120120
source: ./docker/extra_settings
121121
target: /app/docker/extra_settings
122122
postgres:
123-
image: postgres:17.6-alpine@sha256:855021a5b10954343902a8c22a15f8464233126c1d12d9ad84d4a14c5af07a80
123+
image: postgres:18.0-alpine@sha256:aa7c4a8932f5bafe14700a789339d102251d0f7d53503a201247b5f5990da5e2
124124
environment:
125125
POSTGRES_DB: ${DD_DATABASE_NAME:-defectdojo}
126126
POSTGRES_USER: ${DD_DATABASE_USER:-defectdojo}

docs/content/en/open_source/upgrading/2.51.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: 'Upgrading to DefectDojo Version 2.51.x'
2+
title: "Upgrading to DefectDojo Version 2.51.x"
33
toc_hide: true
44
weight: -20250902
5-
description: Helm chart changes.
5+
description: Helm chart changes and Postgres major version updates.
66
---
77

88
## Helm Chart Changes
@@ -44,6 +44,96 @@ The following Helm chart values have been modified in this release:
4444
- **Fixed secret mounting**: Resolved issues with optional secret mounts and references.
4545
- **Improved code organization**: Minor Helm chart refactoring to enhance readability and maintainability.
4646

47+
## PostgreSQL Major Version Upgrade in Docker Compose
48+
49+
This release incorporates a major upgrade of Postgres. When using the default docker compose setup you'll need to upgrade the Postgres data folder before you can use Defect Dojo 2.51.0.
50+
51+
There are lots of online guides to be found such as https://hub.docker.com/r/tianon/postgres-upgrade or https://github.com/pgautoupgrade/docker-pgautoupgrade.
52+
53+
There's also the [official documentation on `pg_upgrade`](https://www.postgresql.org/docs/current/pgupgrade.html), but this doesn't work out of the box when using Docker containers.
54+
55+
Sometimes it's easier to just perform the upgrade manually, which would look something like the steps below.
56+
It may need some tuning to your specific needs and docker compose setup. The guide is loosely based on https://simplebackups.com/blog/docker-postgres-backup-restore-guide-with-examples.
57+
If you already have a valid backup of the postgres 16 database, you can start at step 4.
58+
59+
### 0. Backup
60+
61+
Always back up your data before starting and save it somewhere.
62+
Make sure the backup and restore is tested before continuing the steps below where the docker volume containing the database will be removed.
63+
64+
### 1. Start the Old Postgres Container
65+
66+
If you've acceidentally already updated your docker-compose.yml to the new versions, downgrade to postgres 16 for now:
67+
68+
Edit your `docker-compose.yml` to use the old Postgres version (e.g., `postgres:17.6-alpine`):
69+
70+
```yaml
71+
postgres:
72+
image: postgres:17.6-alpine
73+
...
74+
```
75+
76+
Start only the Postgres container which will now be 17.6:
77+
78+
```bash
79+
docker compose up -d postgres
80+
```
81+
82+
### 2. Dump Your Database
83+
84+
```bash
85+
docker compose exec -t postgres pg_dump -U defectdojo -Fc defectdojo -f /tmp/defectdojo.dump
86+
docker cp <postgres_container_name>:/tmp/defectdojo.dump defectdojo.dump
87+
```
88+
89+
You can find the postgres_container_name via `docker container ls` or `docker ps`.
90+
91+
### 3. Stop Containers and Remove the Old Volume
92+
93+
You can find the volume name via `docker volume ls`.
94+
95+
```bash
96+
docker compose down
97+
docker volume rm <defectdojo_postgres_volume_name>
98+
```
99+
100+
### 4. Switch to the New Postgres Version
101+
102+
Edit your `docker-compose.yml` to use the new version (e.g., `postgres:18-alpine`):
103+
104+
```yaml
105+
postgres:
106+
image: postgres:18-alpine
107+
...
108+
```
109+
110+
### 5. Start the New Postgres Container
111+
112+
```bash
113+
docker compose up -d postgres
114+
```
115+
116+
### 6. Restore Your Database
117+
118+
**Copy the dump file into the new container:**
119+
120+
```bash
121+
docker cp defectdojo.dump <postgres_container_name>:/defectdojo.dump
122+
```
123+
124+
**Restore inside the container:**
125+
126+
```bash
127+
docker exec -it <postgres_container_name> bash
128+
pg_restore -U defectdojo -d defectdojo /defectdojo.dump
129+
```
130+
131+
### 7. Start the Rest of Your Services
132+
133+
```bash
134+
docker compose up -d
135+
```
136+
47137
---
48138

49139
There are other instructions for upgrading to 2.51.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.51.0) for the contents of the release.

0 commit comments

Comments
 (0)