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.

  • Issues in using git forked package in Docker-compose
  • How to run docker-compose on remote host?
  • how to kill lots of docker container processes effectively and faster?
  • docker on OSX not returning container output through ssh,
  • Docker on windows: data in mounted volume doesn't updated
  • Localhost doesn't forward requests to oracle docker container
  • 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?

  • Push to Dockerhub sends entire image instead of just the changes
  • Error setting up docker on Windows
  • How to automatically start services inside a docker container
  • Use container environment variable in docker run without using bash -c
  • Running rust on Docker: Empty reply from server
  • Unrecognized argument format hosting.ini
  • One Solution collect form web for “Data lost after dinghy restart (postgres container)”

    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"
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.