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.

  • Jenkins amazon-ecr plugin issue
  • Docker Best Approach for JAVA Web application (Linux , Oracle DB,Application Server)?
  • running docker request from php
  • Install MySQL connector/J in Docker container
  • What are the option to API gateway with docker?
  • Docker Network Nginx Resolver
  • 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?

  • How to get my hdfs docker client running?
  • how to sync mac local directory with native docker container?
  • Start Docker Daemon as other user
  • Using host JVM to run jar inside a docker container
  • Cloudfront returning 502 errors
  • Gitlab Mocha tests and Docker Tag problems
  • 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.