osx - Run postgres container with data volumes through docker-machine -


i have issue running postgres container set volumes data folder on mac os machine. tried run such this:

docker run \   --name my-postgres \   -e postgres_user=admin \   -e postgres_password=password \   -e postgres_db=some_db_dev \   -v $pg_local_data:/var/lib/postgresql/data \   -d postgres:9.5.1 

every time got following result in logs:

* starting postgresql files belonging database system owned user "postgres". user must own server process.  database cluster initialized locale "en_us.utf8". default database encoding has accordingly been set "utf8". default text search configuration set "english".  data page checksums enabled.  fixing permissions on existing directory /var/lib/postgresql/data ... ok initdb: not create directory "/var/lib/postgresql/data/pg_xlog": permission denied initdb: removing contents of data directory "/var/lib/postgresql/data" 

versions of docker, docker-machine, virtualbox , boot2docker are:

docker-machine version 0.6.0, build e27fb87 docker version 1.10.2, build c3959b1 virtualbox version 5.0.16 r105871 boot2docker 1.10.3 

i saw many publications topic of them outdated. had tried similar solution mysql did not help.

maybe can updated me: solution exist run postgres container data volumes through docker-machine?

thanks!

if running docker-machine on mac, @ time, cannot mount directory not part of local user space (/users/<user>/) without configuration.

this because on mac, docker makes bind mount automatically home ~ directory. remember since docker being hosted in vm isn't local mac os, volume mounts relative host vm - not machine. means default, docker cannot see mac's directories since being hosted on separate vm mac os.

mac os => linux virtual machine => docker                   ^------------------^                    docker can see vm    ^-----------------x----------------^          docker can't see here 

if open virtualbox, can create other mounts (i.e. shared folders) local machine host vm , access them way.

see issue specifics on topic: https://github.com/docker/machine/issues/1826

i believe docker team adding these capabilities in upcoming releases (especially since native mac version in short works).


Comments