Volume on host – permission denied for Postgres (Mac OS)

I am starting Postgresql image with following volume

/Users/me/Desktop/volumes/postgresql/data:/var/lib/postgresql/data

According to docker docs it should work as docker should have access to /Users directory on Mac OS. After creating & runing container I can see
that empty directory /Users/me/Desktop/volumes/postgresql/data is created however Postgres does not start and show these lines in log:

  • How can I create a docker image from the current system?
  • How to copy file from host to container using Dockerfile
  • Huge files in Docker containers
  • JRebel cache on Docker
  • EC2 Instances - Are they Just Containers
  • What is a good style to deploy with docker when docker hub is not available?
  • could not create directory "/var/lib/postgresql/data/global": Permission denied
    

    What I am doing wrong?

  • How to create local mirror for ubuntu inside docker container?
  • Best practices for managing SSH keys with Azure container service deployments
  • Automatically run a script when HBase master Docker container finishes initializing
  • Automatically configure Java to use the maximum RAM allocated to its Docker container
  • Set 'host' as default network for Docker
  • Setting up a remote interpreter in PhpStorm with docker
  • 2 Solutions collect form web for “Volume on host – permission denied for Postgres (Mac OS)”

    Your directory belongs to a different User then the user, that the User that executes the container.

    Could you change your directory like that for a start.

    chmod 777 /Users/me/Desktop/volumes/postgresql/data
    

    If you can start your container with this setting, then this missing permissions are the root cause.

    You could then try to start your container with

    run -u uid ...
    

    and specify the userid of your user on macos.
    You have to create the user in boot2docker too, i.e.

    boot2docker ssh
    sudo sh
    adduser <anyuserid> -u <your uid>
    

    I had the same problem.

    What I done was the workaround by creating the folder inside the Virtual Box.

    Set your docker-compose.yml postgresql folder:

    /Users/me/Desktop/volumes/postgresql/data
    

    to

    /root/data
    

    Enter at the Docker at Virtual Box and create the data folder

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