Docker Community Forums

Share and learn in the Docker community.

Postgres loses data between docker for mac restarts

beta

(Xavier Lange) #1

Expected behavior

I should be able to Quit Docker from the tray app, start docker again, and then “docker start” my postgres container and still see all my databases.

Actual behavior

My rails test suite says:

 PG::ConnectionBad:
   FATAL:  database "rx_test" does not exist

Information

OS X: version 10.11.2 (build: 15C50)
Docker.app: version v1.11.1-beta13
Running diagnostic tests:
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160526-133000.tar.gz
Most specific failure is: No error was detected
Your unique id is: CA263BF5-A5D8-46D6-BB58-26C0079F786A
Please quote this in all correspondence.

Here is a snippet of the docker-compose.yml I’m using:

postgres:
  image: postgres:9.4
  ports:
   - 5432:5432
  volumes:
    - /home/docker/postgres-data:/var/lib/postgresql/data

Steps to reproduce the behavior

  1. Start the docker-compose with that snippet above
  2. Run the “rake db:create” to get things setup
  3. Run test suite to show things working
  4. Stop docker-compose
  5. Shutdown docker
  6. Start docker again and run test suite. You will get an error about missing tables.

(Xavier Lange) #2

I have tried saving the data in a few places. Looks like this an issue with the docker instance losing all volumes between restarts. Choosing a mount point inside of my mac env (/Users/...) I was able to go through the refresh cycle and keep my databases. Is this the expected behavior?


(David Sheets) #3

Hi Xavier,

Yes, this is the expected behavior right now. We are working on making this mountpoint management easier and hope to have something out to Beta users soon. See https://beta.docker.com/docs/mac/osxfs/#namespaces for more information.

Thanks for participating in the Docker for Mac Beta!

David