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.

  • How to avoid NoSuchMethodError in docker-client test program
  • How to correctly install RVM in Docker?
  • How does one specify a particular cipher suite for a nginx docker instance?
  • Minecraft Docker Image: game storage persistence
  • How to disable write barrier on docker thinpooldev?
  • Docker Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Ubuntu
  • 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?

  • Docker Swarm Mode service anti-affinity
  • docker hub images tags are not showing using automated build from github organisation repo
  • Is it practical to deploy an asterisk server using Docker?
  • How to run nodemon and different gulp tasks in a docker container
  • How to stop all containers when one container stops with docker-compose?
  • Docker container for Swagger UI not loading
  • 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.