# Utilizzare un database PGSQL al di fuori di Docker?

**URL:** https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679
**Category:** Self-hosting
**Created:** [24 Novembre 2018, 7:33pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679 "2018-11-24T19:33:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ylluminate](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ylluminate/32/115440_2.png) [@ylluminate](https://meta.discourse.org/u/ylluminate)
#### Post date: [24 Novembre 2018, 7:33pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/1 "2018-11-24T19:33:24Z")

</div>

I’m doing the standard Docker installation of Discourse, however it appears that there are some quirks regarding the database. First, I don’t see any listing for a `production` database within the `config/database.yml` (only `development`, `test` and `profile`), but it appears that the Dockerized system is using PostgreSQL.

What is the proper method for directing the standard Dockerized installation to use a PostgreSQL database on another server?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [24 Novembre 2018, 7:37pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/2 "2018-11-24T19:37:12Z")

</div>

I would start with

> [@Configure Discourse to use a separate PostgreSQL server](https://meta.discourse.org/t/running-discourse-with-a-separate-postgresql-server/46375):
>
> Let’s say you’re using AWS RDS, or an existing PostgreSQL server managed elsewhere. It’s fairly straightforward to get Discourse to use such a setup, without needing to grant superuser privileges to anything that Discourse itself runs. Here’s how. Prerequisites Discourse requires PostgreSQL’s major version to [match what we ship with in our docker images](https://github.com/discourse/discourse_docker/blob/main/image/base/Dockerfile#L37); if you try to run on a newer or older version, it might work, but we don’t guarantee it, and if something breaks in the future, you get to …

Can’t promise it still doesn’t use Docker, but it might get you started on the right track.

---

<div class="post-metadata">

### Author: ![ylluminate](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ylluminate/32/115440_2.png) [@ylluminate](https://meta.discourse.org/u/ylluminate)
#### Post date: [25 Novembre 2018, 10:58pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/3 "2018-11-25T22:58:09Z")

</div>

Thanks @cpradio this worked out rather well and works with any database (ie, even non-Docker database instances), but there was one major hiccup: It’s not made clear that the process will not transfer the database info over and any existing tables will be effectively lost.

I guess the followup would be: If one were to want to retain the data after moving to a separate database, what’s the process for that?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [25 Novembre 2018, 11:15pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/4 "2018-11-25T23:15:33Z")

</div>

> [@ylluminate](#):
>
> I guess the followup would be: If one were to want to retain the data after moving to a separate database, what’s the process for that?

Take a backup before, restore after.

---

<div class="post-metadata">

### Author: ![ylluminate](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ylluminate/32/115440_2.png) [@ylluminate](https://meta.discourse.org/u/ylluminate)
#### Post date: [25 Novembre 2018, 11:19pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/5 "2018-11-25T23:19:54Z")

</div>

Yeah, was afraid you’d say that @Falco. 😉 I guess the question evolves to be: how do you get a backup of the pgsql instance that Discourse is using / how do you get into that instance? `./launcher enter postgres`?

So I’ve removed the template line from the `app.yml`, I guess that means I need to put that back in and then `./launcher rebuild app`? Or is there a better way?

And if I do this, does that mean it will try to use the Docker pgsql db again and thus screw the app up temporarily while I have that active?

I guess a kind of complete snapshot of what’s happening there and how to interact with it and what’s to be expected (such as perhaps the new external db no longer being used temporarily while recovering the Dockerized pgsql instance)…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [22 Settembre 2021, 9:29pm UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/6 "2021-09-22T21:29:04Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 Ottobre 2021, 12:32am UTC](https://meta.discourse.org/t/using-a-pgsql-database-outside-of-docker/102679/7 "2021-10-12T00:32:44Z")

</div>


