# Move the postgresql database out of the docker container

**URL:** <https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425>\
**Category:** PMM 2.x\
**Created:** [September 25, 2023, 9:13am UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425 "2023-09-25T09:13:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbas](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dbas](https://forums.percona.com/u/dbas)\
**Post date:** [September 25, 2023, 9:13am UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/1 "2023-09-25T09:13:39Z")

</div>

## Description:

Hello,

Is it possible to move the postgresql database out of the docker container as we have estimated a volume of up to 1TB?

Thank you

Best regards

## Version:

2.37

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [September 25, 2023, 12:37pm UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/2 "2023-09-25T12:37:43Z")

</div>

It is possible to do and details can be found [here](https://docs.percona.com/percona-monitoring-and-management/details/postgresql.html).

The postgres database will no longer be managed as a component of PMM so you’ll have to do your own upgrades and ensure you’re using a compatible version with PMM server (which shouldn’t be an issue unless you tried to jump to PG16 while PMM is still using 14.8)

I’m curious though…given the PG database only holds information about client registrations (and soon grafana configurations)…how are you calculating 1TB of data? I’d think you’d need billions of clients to get that database that big. Did you instead mean you expect 1TB of metrics data? In that case you may be looking to externalize VictoriaMetrics (which holds the Time Series metrics) and I’m not sure if that can be externalized yet.

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [September 25, 2023, 3:42pm UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/3 "2023-09-25T15:42:44Z")

</div>

Heard back on the ability to externalize VictoriaMetrics and it’s actually slated for the next release (2.40.0) that should be coming out in a few weeks. So if it’s more metrics you’re worried about hitting 1TB that could help!

---

<div class="post-metadata">

**Author:** ![dbas](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dbas](https://forums.percona.com/u/dbas)\
**Post date:** [September 28, 2023, 12:45pm UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/4 "2023-09-28T12:45:11Z")

</div>

Hello,

I read the documentation [How much disk space should I allocate for Percona Monitoring and Management?](https://www.percona.com/blog/how-much-disk-space-should-i-allocate-for-percona-monitoring-and-management/) “will push you above 230MB/host/day” so 7GB by host for one month

Thank you

Best regards

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [September 28, 2023, 2:43pm UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/5 "2023-09-28T14:43:58Z")

</div>

I’d have to take a look but that Blog was against PMM 1.x using prometheus for time-series data. We’ve since moved to VictoriaMetrics (a prometheus compatible database) and their compression cuts disk usage _dramatically_! Our QA Manager [wrote a blog](https://www.percona.com/blog/observations-on-better-resource-usage-with-percona-monitoring-and-management-v2-12-0/) on his observations when we made the switch.

All that to say, externalizing the Postgres database won’t give you much help…the biggest database will be the VictoriaMetrics database for metrics (not yet externlizable) followed by Clickhouse for Query Analytics data ([can be externalized](https://docs.percona.com/percona-monitoring-and-management/details/clickhouse.html)).

One of the things I’ve done is switch from using a data container to maintain state to instead using a mapped volume in docker and then all my PMM data is stored on the hosts /srv (or whatever you map to) which is actually a NAS but could be DASD or whatever you want with high IOps.

---

<div class="post-metadata">

**Author:** ![dbas](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dbas](https://forums.percona.com/u/dbas)\
**Post date:** [September 28, 2023, 8:34pm UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/6 "2023-09-28T20:34:37Z")

</div>

Hello,

We try to use local db postgresql but we see that on docker postgresql image :  
87ca272892e7 localhost/percona/pmm-server:2.37.0 postgres -c share… 7 hours ago Created external-postgres

On /root/.config/systemd/user/pmm-server.service  
Environment=PERCONA\_TEST\_POSTGRES\_ADDR=127.0.0.1  
Environment=PERCONA\_TEST\_POSTGRES\_PORT=5111  
Environment=PERCONA\_TEST\_POSTGRES\_DBNAME=postgres  
Environment=PERCONA\_TEST\_POSTGRES\_USERNAME=pmm  
ExecStart=/usr/bin/podman run --rm --replace=true --name=%N -p ${PMM\_PUBLIC\_PORT}:443/tcp -e ${PERCONA\_TEST\_POSTGRES\_ADDR} -e ${PERCONA\_TEST\_POSTGRES\_ADDR} -e ${PERCONA\_TEST\_POSTGRES\_PORT} -e ${PERCONA\_TEST\_POSTGRES\_USERNAME} -e ${PERCONA\_TEST\_POSTGRES\_DBPASSWORD} -e ${PERCONA\_TEST\_POSTGRES\_DBNAME} --ulimit=host --volume=${PMM\_VOLUME\_NAME}:/pmm --env-file=${PMM\_ENV\_FILE} --health-cmd=none --health-interval=disable ${PMM\_IMAGE}:${PMM\_TAG}

Thank you

Regards

---

<div class="post-metadata">

**Author:** ![dbas](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dbas](https://forums.percona.com/u/dbas)\
**Post date:** [October 10, 2023, 10:47am UTC](https://forums.percona.com/t/move-the-postgresql-database-out-of-the-docker-container/25425/7 "2023-10-10T10:47:04Z")

</div>

Hello,

We try to use external postgresql db, below ~/.config/systemd/user/pmm-server.service :  
[Unit]  
Description=pmm-server  
Wants=network-online.target  
After=network-online.target  
After=nss-user-lookup.target nss-lookup.target  
After=time-sync.target

[Service]  
Type=simple

# set environment for this unit

Environment=PMM\_PUBLIC\_PORT=443  
Environment=PERCONA\_TEST\_POSTGRES\_ADDR=127.0.0.1  
Environment=PERCONA\_TEST\_POSTGRES\_PORT=5000  
Environment=PERCONA\_TEST\_POSTGRES\_DBNAME=postgres  
Environment=PERCONA\_TEST\_POSTGRES\_USERNAME=pmm  
Environment=PERCONA\_TEST\_POSTGRES\_DBPASSWORD=test  
Environment=PERCONA\_TEST\_POSTGRES\_SSL\_MODE=DISABLE  
Environment=PMM\_VOLUME\_NAME=%N  
Environment=PMM\_TAG=2.37.0  
Environment=PMM\_IMAGE=localhost/percona/pmm-server  
Environment=PMM\_ENV\_FILE=%h/.config/pmm-server/pmm-server.env

# optional env file that could override previous env settings for this unit

EnvironmentFile=-%h/.config/pmm-server/env

ExecStart=/usr/bin/podman run --rm --network=host --replace=true --name=%N -p ${PMM\_PUBLIC\_PORT}:443/tcp -e ${PERCONA\_TEST\_POSTGRES\_ADDR} -e ${PERCONA\_TEST\_POSTGRES\_PORT} -e ${PERCONA\_TEST\_POSTGRES\_USERNAME} -e ${PERCONA\_TEST\_POSTGRES\_DBPASSWORD} -e ${PERCONA\_TEST\_POSTGRES\_DBNAME} --ulimit=host --volume=${PMM\_VOLUME\_NAME}:/pmm --env-file=${PMM\_ENV\_FILE} --health-cmd=none --health-interval=disable ${PMM\_IMAGE}:${PMM\_TAG}  
ExecStop=/usr/bin/podman stop -t 10 %N  
Restart=on-failure  
RestartSec=20

[Install]  
Alias=%N  
WantedBy=default.target

But applicance connect always on pg database on pmm container.

Is it possible to use this configuration ?

Thank you

Regards
