{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/22258","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/22258/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/22258/comments","events_url":"https://api.github.com/repos/docker/docker/issues/22258/events","html_url":"https://github.com/docker/docker/issues/22258","id":150428886,"number":22258,"title":"Mounting volumes and mapping host user to docker user","user":{"login":"smith64fx","id":3246782,"avatar_url":"https://avatars.githubusercontent.com/u/3246782?v=3","gravatar_id":"","url":"https://api.github.com/users/smith64fx","html_url":"https://github.com/smith64fx","followers_url":"https://api.github.com/users/smith64fx/followers","following_url":"https://api.github.com/users/smith64fx/following{/other_user}","gists_url":"https://api.github.com/users/smith64fx/gists{/gist_id}","starred_url":"https://api.github.com/users/smith64fx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smith64fx/subscriptions","organizations_url":"https://api.github.com/users/smith64fx/orgs","repos_url":"https://api.github.com/users/smith64fx/repos","events_url":"https://api.github.com/users/smith64fx/events{/privacy}","received_events_url":"https://api.github.com/users/smith64fx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-22T17:36:46Z","updated_at":"2016-04-22T18:00:03Z","closed_at":null,"body":"I want to start a docker container (postgres) and mount the folder /var/lib/postgres/data to my local system.\r\n\r\n```\r\ndocker run -e POSTGRES_PASSWORD=123456 -v `pwd`/postgres:/var/lib/postgresql/data postgres\r\n```\r\n\r\nOn my Host: ./postgres has the right owner. Nice!\r\nBut inside Container: /var/lib/postgresql/data has the owner root:root. the postgres user cannot access the /var/lib/postgresql/data folder...\r\n\r\nNow my question.\r\n\r\n**How can I tell docker, to map my local user smith:staff to the postgres:postgres user inside the container?**\r\n\r\n\r\nbtw: i also tried it with\r\n```\r\ndocker run -u postgres:postgres -e POSTGRES_PASSWORD=123456 -v `pwd`/postgres:/var/lib/postgresql/data postgres\r\n```\r\n\r\nUsing this command, my postgres won't start at all.\r\n\r\n\r\n#21702 \r\n```\r\nClient:\r\n Version:      1.11.0\r\n API version:  1.23\r\n Go version:   go1.5.4\r\n Git commit:   4dc5990\r\n Built:        Wed Apr 13 19:36:04 2016\r\n OS/Arch:      darwin/amd64\r\n\r\nServer:\r\n Version:      1.11.0\r\n API version:  1.23\r\n Go version:   go1.5.4\r\n Git commit:   a5315b8\r\n Built:        Mon Apr 18 19:19:21 2016\r\n OS/Arch:      linux/amd64\r\n```\r\n\r\n\r\n**Output of `docker info`:**\r\n\r\n```\r\nContainers: 3\r\n Running: 3\r\n Paused: 0\r\n Stopped: 0\r\nImages: 10\r\nServer Version: 1.11.0\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 154\r\n Dirperm1 Supported: true\r\nLogging Driver: json-file\r\nCgroup Driver: cgroupfs\r\nPlugins:\r\n Volume: local\r\n Network: null host bridge\r\nKernel Version: 4.4.6\r\nOperating System: Alpine Linux v3.3\r\nOSType: linux\r\nArchitecture: x86_64\r\nCPUs: 2\r\nTotal Memory: 1.956 GiB\r\nName: docker\r\nID: IY64:5E2P:FPZB:G3DH:32BS:5IXL:EHF6:5XC6:HL7D:HKU6:7OBK:U3J4\r\nDocker Root Dir: /var/lib/docker\r\nDebug mode (client): false\r\nDebug mode (server): true\r\n File Descriptors: 29\r\n Goroutines: 70\r\n System Time: 2016-04-22T17:15:36.809782696Z\r\n EventsListeners: 2\r\nRegistry: https://index.docker.io/v1/\r\n```\r\n\r\n**Additional environment details (AWS, VirtualBox, physical, etc.):**\r\nDocker Beta for OSX\r\n\r\n\r\n**Steps to reproduce the issue:**\r\n1. \r\n2.\r\n3.\r\n\r\n\r\n**Describe the results you received:**\r\n\r\n\r\n**Describe the results you expected:**\r\n\r\n\r\n**Additional information you deem important (e.g. issue happens only occasionally):**\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/213530771","html_url":"https://github.com/docker/docker/issues/22258#issuecomment-213530771","issue_url":"https://api.github.com/repos/docker/docker/issues/22258","id":213530771,"user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T18:00:03Z","updated_at":"2016-04-22T18:00:03Z","body":"The issue is the entrypoint script is expecting root access when it first starts up: https://github.com/docker-library/postgres/blob/master/9.5/docker-entrypoint.sh\r\nSo when you start with `-u postgres:postgres`  it can't startup.\r\n\r\nIn the short term it would be best to use an image that's ready to go with the correct uid/gid."}}