# Named volume with postgresql doesn't keep database's data

**URL:** <https://forums.docker.com/t/named-volume-with-postgresql-doesnt-keep-databases-data/7434>\
**Category:** General\
**Created:** [March 15, 2016, 12:59am UTC](https://forums.docker.com/t/named-volume-with-postgresql-doesnt-keep-databases-data/7434 "2016-03-15T00:59:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxwoodswebsites](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@foxwoodswebsites](https://forums.docker.com/u/foxwoodswebsites)\
**Post date:** [March 15, 2016, 12:59am UTC](https://forums.docker.com/t/named-volume-with-postgresql-doesnt-keep-databases-data/7434/1 "2016-03-15T00:59:46Z")

</div>

Hi all,

I have the following docker-compose.yml with the app & nginx containers removed:

> ```
> version: '2'
> services:
> postgres:
> restart: always
> image: postgres:latest
> volumes:
> - dbdatavol:/var/lib/postgresql
> ports:
> - "5433:5432"
> volumes:
> dbdatavol:
> driver: local
> 
> ```

When I bring this up with docker-compose, and run the commands to create the database, everything works fine. But after bringing it down, and back up, the data is gone from the database. I’ve touched a file in the volume, and it is still there, but using psql to login to the server, all the tables have been removed. Anyone know what I’m doing wrong? docker v. 1.10.3, and docker-compose 1.6.2

---

<div class="post-metadata">

**Author:** ![foxwoodswebsites](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@foxwoodswebsites](https://forums.docker.com/u/foxwoodswebsites)\
**Post date:** [March 21, 2016, 3:18am UTC](https://forums.docker.com/t/named-volume-with-postgresql-doesnt-keep-databases-data/7434/2 "2016-03-21T03:18:21Z")

</div>

For posterity: the answer was that the postgres image creates a volume specifically on the sub-directory /var/lib/postgresql/data. Changing my volume to reference that directory kept the database alive between ups and downs.
