# Cannot backup (connect to postgres) in docker\_dev

**URL:** https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672
**Category:** Bug
**Created:** [February 2, 2018, 9:13pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672 "2018-02-02T21:13:28Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 2, 2018, 9:13pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/1 "2018-02-02T21:13:28Z")

</div>

Using the docker\_dev you can’t make a backup from the web interface or from within the container using `./script/discourse backup`. Both fail due to postgres permissions issues. This makes using the container to do an import problematic.

What I’ve been doing is editing `/etc/postgresql/9.5/main/pg_hba.conf` and changing the connections from “peer” to “trust”, like this:

```plaintext
local all postgres trust
local all all trust

```

And then restarting the container, as I’ve yet to figure out how to restart postgres from within it.

This likely isn’t the best solution to this problem, and I don’t even know where to look to fix it if I did.

And while I’m complaining, it would be nice if the container included `libmysqlclient-dev`

---

<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: [February 5, 2018, 9:07pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/2 "2018-02-05T21:07:44Z")

</div>

Feel free to submit a couple of PRs to improve this.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 5, 2018, 9:09pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/3 "2018-02-05T21:09:26Z")

</div>

Can you give me a hint where that happens? I’m not clear where that container gets built. Its not in discourse/discourse, is it?

---

<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: [February 5, 2018, 9:12pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/4 "2018-02-05T21:12:11Z")

</div>

The container is built here:

> **[discourse\_docker/image/discourse\_dev at master · discourse/discourse\_docker](https://github.com/discourse/discourse_docker/tree/master/image/discourse_dev)**
>
> master/image/discourse\_dev

Sorry for being somewhat abrupt I am very ✈ 🕰ed

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 5, 2018, 9:26pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/5 "2018-02-05T21:26:17Z")

</div>

Welcome home, or away. 🙂

So I’d fix up `~/src/discourse_docker/image/discourse_dev/postgres_dev.template.yml` and submit the PR and **then** after you accepted the PR and rebuilt the image, I could test whether it really worked, right?

If that’s the process, then I think I could contrive to modify `~/src/discourse/bin/docker/boot_dev` to pull my version of that image to test it.

I’ve got three imports running right now. I think that I may end up just spinning up Digital Ocean droplets to run them, but this could be one way to manage running multiple imports at once on a single machine. Or maybe I should be cranking up a VM in VirtualBox. . .

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 25, 2018, 10:18pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/6 "2018-02-25T22:18:48Z")

</div>

Well, this isn’t quite the specific problem that I was dealing with, but [FIX: reset\_db by pfaffman · Pull Request #5617 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5617) gets `bin/docker/reset_db` to work.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 25, 2018, 11:38pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/7 "2018-02-25T23:38:33Z")

</div>

Sorry to be dense, but how is the container built?

I was happy to learn that `image/Readme.md` says

```plaintext
To build a new set of images, update the `Makefile` with the new version number, and then `make all`. 

```

Sounds simple. Sadly, there is no Makefile to be found.

Then I thought that I could just build with

```
cd images; docker build discourse_dev

```

(And I tried running that from some other directories..) but that fails with

```plaintext
Step 6/17 : ADD redis.template.yml /pups/redis.yml
ADD failed: stat /var/lib/docker/tmp/docker-builder410839948/redis.template.yml: no such file or directory

```

I’m running out of ideas.

---

<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: [February 25, 2018, 11:39pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/8 "2018-02-25T23:39:47Z")

</div>

Oh we probably want to update this, I think build.rb in the repo takes care of it these days.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 25, 2018, 11:48pm UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/9 "2018-02-25T23:48:35Z")

</div>

> [@sam](#):
>
> Oh we probably want to update this, I think build.rb in the repo takes care of it these days.

OK. That’d be great. Per the above, I wanted to do something like this:

I wanted to add this to `Dockerfile`:

```plaintext
# Add libmysqlclient-dev for running imports
RUN apt-get update && apt-get install -y libmysqlclient-dev

```

And also, the database stuff in the OP. I don’t fully understand the security implications of the `trust` that I suggested, but I can’t get backups to work without the change. This is what I’m doing to run an import in `discourse_dev`

```plaintext
./bin/docker/shell_root
rm /etc/apt/sources.list.d/google-chrome.list
apt update
apt -y install libmysqlclient-dev
sed -i -e 's/peer/trust/g' /etc/postgresql/9.5/main/pg_hba.conf
exit
docker restart discourse_dev
./bin/docker/shell
time bundle exec ruby /src/script/import_scripts/vbulletin.rb # for example

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 9, 2018, 7:12am UTC](https://meta.discourse.org/t/cannot-backup-connect-to-postgres-in-docker-dev/79672/10 "2018-07-09T07:12:19Z")

</div>


