Moby: docker created files in volumes as root, it's there any way to make it as current user ?

Created on 12 Aug 2015  路  3Comments  路  Source: moby/moby

I want use Django in docker and add local directory as volumes mount into it, but when I use manage.py create some files. all files create by "root", is there any way to make them belong to my current user ?

All 3 comments

Hi!

Please read this important information about creating issues.

If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.

If you suspect your issue is a bug, please edit your issue description to include the BUG REPORT INFORMATION shown below. If you fail to provide this information within 7 days, we cannot debug your issue and will close it. We will, however, reopen it if you later provide the information.

This is an automated, informational response.

Thank you.

For more information about reporting issues, see https://github.com/docker/docker/blob/master/CONTRIBUTING.md#reporting-other-issues


BUG REPORT INFORMATION

Use the commands below to provide key information from your environment:

docker version:
docker info:
uname -a:

Provide additional environment details (AWS, VirtualBox, physical, etc.):

List the steps to reproduce the issue:
1.
2.
3.

Describe the results you received:

Describe the results you expected:

Provide additional info you think is important:

----------END REPORT ---------

ENEEDMOREINFO

$ docker version

Client API version: 1.19
Package Version (client): docker-1.7.1-7.gitd5a81b3.fc22.x86_64
Go version (client): go1.4.2
Git commit (client): d5a81b3/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1.fc22
Server API version: 1.19
Package Version (server): docker-1.7.1-7.gitd5a81b3.fc22.x86_64
Go version (server): go1.4.2
Git commit (server): d5a81b3/1.7.1
OS/Arch (server): linux/amd64

$ docker info

Containers: 8
Images: 100
Storage Driver: devicemapper
 Pool Name: docker-253:1-404319-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: extfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 4.575 GB
 Data Space Total: 107.4 GB
 Data Space Available: 39.96 GB
 Metadata Space Used: 7.352 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.14 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93 (2015-01-30)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.3-201.fc22.x86_64
Operating System: Fedora 22 (Twenty Two)
CPUs: 4
Total Memory: 11.44 GiB
Name: kyan.xxx.xxx.xxx.com
ID: V6E4:XJB2:BURJ:SRYK:D6VW:2BDW:CFNH:BT4J:G54A:NSK5:OQEP:C4H3


$ uname -a

Linux kyan.laptop.nay.redhat.com 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Provide additional environment details (physical.):

List the steps to reproduce the issue:

  1. create a configuration follow https://docs.docker.com/compose/django/ , (before "Build the project")
  2. add privileged in docker-compose.yml or execute sudo setenforce 0 to make container cloud write file into volumes.
  3. run docker-compose run web django-admin.py startproject composeexample .
  4. the files generated by Django were created by 'root' user

My question is: Is there any way to make the container generated files use host user and group ?

drwxr-xr-x. 2 root root 4.0K Aug 12 09:21 composeexample
-rwxr-xr-x. 1 kyan kyan  360 Aug 12 09:21 docker-compose.yml
-rwxr-xr-x. 1 kyan kyan  146 Aug 11 18:59 Dockerfile
-rwxr-xr-x. 1 root root  255 Aug 12 08:52 manage.py
-rwxr-xr-x. 1 kyan kyan   99 Aug 11 18:46 requirements.txt

I found a solution, just add --user 1000:1000
or add in docker-compose.yml

user: "1000:1000"
Was this page helpful?
0 / 5 - 0 ratings