Alkis Kalogeris
Alkis Kalogeris

Reputation: 17745

Data lost after dinghy restart (postgres container)

I'm creating a container using this docker-compose.yml

postgresdb:
  container_name: "postgresdb"
  image: "postgres:9.5"
  volumes:
    - "/var/docker/data/postgresdb:/var/lib/postgresql/data"
  ports:
    - "5432:5432"
  environment:
    VIRTUAL_HOST: "postgresdb.docker"
    VIRTUAL_PORT: "5432"
    POSTGRES_DB: "dev"

After running my container for the first time, I create some tables in my db. After that I stop my container and stop dinghy (dinghy halt). After that I start dinghy (dinghy up) and start the postgres container. The tables now are gone.

I checked inside dinghy vm and the mounted volume is there.

Versions

Macbook pro
Dinghy 4.3.1
docker-machine version 0.6.0, build e27fb87
docker-compose version 1.6.2, build 4d72027
Virtualbox 5.0.16 r105871 (with the latest extension pack)
Docker version 1.10.3, build 20f81dd

When I removed the volumes mounting from docker-compose.yml and restarted dinghy it worked as expected. Of course the data will be lost if I delete the container which is expected.

So the question still stands for the mounted volumes. Perhaps the api for mounted volumes has changed? I've read about the new way of doing things, but isn't this supposed to be backwards compatible?

Upvotes: 3

Views: 1743

Answers (1)

Alkis Kalogeris
Alkis Kalogeris

Reputation: 17745

https://github.com/codekitchen/dinghy/issues/162

This isn't unique to dinghy, it's due to docker-machine using a root volume that isn't persisted across reboots. I'd recommend using a named volume if you want the data to persist, rather than a hard-coded path inside the linux VM. For instance:

  volumes:
    - "mydatavol:/var/lib/postgresql/data"

Upvotes: 1

Related Questions