# Docker base image with PostgreSQL 10 released

**URL:** https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536
**Category:** Announcements
**Tags:** docker
**Created:** [April 4, 2018, 7:08am UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536 "2018-04-04T07:08:39Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [June 25, 2018, 5:07am UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/30 "2018-06-25T05:07:59Z")

</div>

```plaintext
> df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 396M 41M 355M 11% /run
/dev/vda1 58G 27G 32G 47% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/vda15 105M 3.4M 102M 4% /boot/efi
/dev/sda1 246G 56G 178G 24% /mnt/volume-fra1-01-part1
tmpfs 396M 0 396M 0% /run/user/0

```

Upgrading PostgreSQL from version 9.5 to 10  
WARNING: Upgrading PostgresSQL would require an addtional 1.5M of disk space  
Please free up some space, or expand your disk, before continuing.

So, is the issue with `/dev/vda1`?  
If so, should a swap file help?  
If not, what do I do next?

I tried to remove a backup, which was 1GB, but it didn’t help.

---

<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: [June 25, 2018, 3:49pm UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/31 "2018-06-25T15:49:18Z")

</div>

Hey, @meglio. I’m working on a script that will help debug this particular issue. Could you give me the output of these two commands?

```
  echo df -h / /var/discourse /var/lib/docker /var/lib/docker/* |uniq | tee >> $LOG_FILE
  sudo docker exec -w /var/www/discourse -i $YML df -h /shared /shared/backups /shared/uploads /shared/postgres_data /shared/redis_data |uniq

```

Also, I submitted [this PR](https://github.com/discourse/discourse_docker/pull/394) a while back that might help with this issue (though I’m not clear what your issue is at this point).

---

<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: [August 2, 2018, 9:51pm UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/33 "2018-08-02T21:51:00Z")

</div>

12 posts were split to a new topic: [Upgrade of Postgres failed due to corrupted database?](https://meta.discourse.org/t/upgrade-of-postgres-failed-due-to-corrupted-database/93808)

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [September 10, 2018, 1:37am UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/34 "2018-09-10T01:37:01Z")

</div>

```plaintext
echo df -h / /var/discourse /var/lib/docker /var/lib/docker/* |uniq | tee >> $LOG_FILE

```

Output:

> -bash: $LOG\_FILE: ambiguous redirect

@pfaffman

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [November 26, 2018, 4:56am UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/35 "2018-11-26T04:56:44Z")

</div>

> [@pfaffman](#):
>
> Hey, @meglio. I’m working on a script that will help debug this particular issue. Could you give me the output of these two commands?

Hi @pfaffman, I just tried again now and the issue is the same - still can’t upgrade to PostgreSQL 10, it asks me for 2…10MB of free space.

Even after cleaning up with `apt-get autocleanup`, which freed ~800MB of space, it still asks me for 8MB of free space.

```plaintext
:/var/discourse df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 396M 5.7M 390M 2% /run
/dev/vda1 58G 31G 28G 53% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/vda15 105M 3.4M 102M 4% /boot/efi
/dev/sda1 246G 59G 175G 26% /mnt/volume-fra1-01-part1
tmpfs 396M 0 396M 0% /run/user/0
overlay 58G 31G 28G 53% /var/lib/docker/overlay2/efed3d1d9b0c613c0c33f0988390802d301cc0214d988a971da0f466d421d19d/merged
shm 512M 4.0K 512M 1% /var/lib/docker/containers/4ce1664f6c21aa8ccf7c69281f5b1a3e6d13d9d406b93a39241604bda0700e84/mounts/shm

```

Any ideas how to workaround?

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [November 26, 2018, 6:27am UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/36 "2018-11-26T06:27:14Z")

</div>

I came up with an idea that I’m trying to implement, but have encountered a few obstacles.

I have a 250GB volume attached to the droplet. So I decided to create a folder: `/shared/standalone/t` and symlink it to a folder in the volume.

Next, I edited the `postgres.template.yml` and changed all references of `/shared/postgres_data_new` to `/shared/t/postgres_data_new`.

What I expect is that `/shared/` of the container gets mounted to `/var/discourse/shared/standalone/`, and then when the postgres 9.5\>10 upgrade process starts, it will create `/var/discourse/shared/standalone/t/postgres_data_new`, which in fact will be created at the 250G volume.

However, when the postgres upgrade process starts, it fails with the following error:

> install: cannot create directory ‘/shared/t’: File exists

Why does it try to create a `/shared/t` directory, and not `/shared/t/postgres_data_new`. What am I missing in the `postgres.template.yml` file?

P.S. I also commented out the following section:

```plaintext
# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
         # required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))

         #if ["$free_disk" -lt "$required"]; then
         # echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
         # echo "Please free up some space, or expand your disk, before continuing."
         # echo ''
         # echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
         # exit 1
         #fi

```

_UPD._

Finally, I succeeded upgrading Postgres from 9.5 to 10 with limited disk space.

So, here is how.

## Upgrading PostgreSQL from 9.5 to 10 with limited disk space

So if your disk is e.g. 60GB and system + database takes 35GB, you won’t be able to update Postgres to the newer major version, as it requires free space that is 2x of the database space.

Here is a workaround that worked for me.

**Step 1.** Buy / mount a volume (this is only needed temporarily). Create a folder in the volume. In my case the folder name is `t`.

**Step 2.** Edit `containers/app.yml` and add a new volume:

```yaml
- volume:
      host: /mnt/volume-fra1-01-part1/t
      guest: /shared/t

```

In this example, `/mnt/volume-fra1-01-part` is the path to the mounted volume. Change it to reflect yours.

**Step 3.** Backup your `templates/postgres.template.yml` file, then edit it:

Find `path: /root/upgrade_postgres` and comment out the following section:

```txt
# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
         # required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))

         #if ["$free_disk" -lt "$required"]; then
         # echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
         # echo "Please free up some space, or expand your disk, before continuing."
         # echo ''
         # echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
         # exit 1
         #fi

```

Also, change all references of:

- `/shared/postgres_data_new` to `/shared/t/postgres_data_new`
- `/shared/postgres_data_old` to `/shared/t/postgres_data_old`

(the /t/ is added to the path).

**Step 4.** Rebuild your Discourse instance:

```plaintext
cd /var/discourse
./launcher rebuild app

```

**Step 5** Edit file `app.yml` and remove the volume we added previously. Restore the `postgres.template.yml`

**Step 6.** Rebuild your Discourse instance again.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [December 1, 2023, 12:28pm UTC](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536/37 "2023-12-01T12:28:31Z")

</div>



[Previous page](https://meta.discourse.org/t/docker-base-image-with-postgresql-10-released/84536.md?page=1)
