Docker Volume another disk

I am using docker 1.9.1 and compose 1.6, I have am using the standard postgres container postgres:9.3.5 which has a data volume at /var/lib/postgresql/data I want to externally mount that file into /data which is a different disk ( not the root partition). I added the following to my compose file.

 - /data/pg_data:/var/lib/postgresql/data

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       63G  5.9G   57G  10% /
devtmpfs        7.5G  120K  7.5G   1% /dev
tmpfs           7.5G     0  7.5G   0% /dev/shm
/dev/xvdb       985G  197M  934G   1% /data

starting the container results in my data volume not being present on /data. docker inspect reveals the following.

  • Configure reverse-proxy for Keycloak docker with custom base URL
  • How to detect a docker daemon port
  • installing `lightdm` in Dockerfile raises interactive keyboard layout menu
  • Docker containers on AWS
  • Deploying web service application using Docker
  • Mounting Azure File Storage in Docker container via Kubernetes
  • Mounts": [
                "Source": "/data/pg_data",
                "Destination": "/var/lib/postgresql/data",
                "Mode": "rw",
                "RW": true

    if I use a symlink instead

    /docker -> /data/pg_data 

    and update the docker-compose file accordingly, it all works. The data is in the right place on /data

    Any ideas whats going on?

  • How does docker work along with IBM WebSphere?
  • crontab not working ubuntu 16.04
  • What docker commands does rancher run when I perform an upgrade
  • Push Docker Images to Google Cloud using Visual Studio Online
  • Deploy a docker image from a registry with basic auth
  • How to backup MongoDB in a setup with multiple Docker containers?
  • 2 Solutions collect form web for “Docker Volume another disk”

    Are you using VirtualBox?
    You can create a separate volume and mount it on the Postgres container:

    $ docker volume create --name postgres_data

    And in the docker-compose.yml:

    version: "2"
          - postgres_data:/var/lib/postgresql/data
        external: true

    You can mount the volume in another container and backup the data:

    $ docker run -it -v postgres_data:/postgres_data $PWD:/backup alpine sh
    $ cp -rf /postgres_data /backup/

    I ended up upgrading docker to 1.9.1 and the problem went away. I couldn’t find a bug in the docker release notes that sounds related but it definitely has fixed the issue on several machines.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.