7

I followed all steps described here: https://docs.docker.com/compose/django/

Everything runs, but the problem is that created files are owned by root. I have no idea how to change it.

I'm able to run docker run hello-world - no sudo required.

The command I run: docker-compose run web django-admin.py startproject composeexample .

Any clues how to force compose to use my user as the owner?

tunarob
  • 2,768
  • 4
  • 31
  • 48
  • 1
    Did you, by any chance, set the sticky bit on the docker client? `ls -la \`which docker\`` – WooDzu Nov 03 '15 at 22:48
  • ls -la `which docker` => `-rwxr-xr-x 1 root root 28350112 Nov 3 17:48 /usr/bin/docker` – tunarob Nov 03 '15 at 22:50
  • Perhaps adding this to the yml file for `web` servcie may do the trick: `user: $UID`. – WooDzu Nov 03 '15 at 22:57
  • It says this var is not defined – tunarob Nov 03 '15 at 23:08
  • What's your docker-compose version? Interpolating variables has only just been added to 1.5. See https://github.com/docker/compose/releases – WooDzu Nov 03 '15 at 23:12
  • When `user: ${UID}` I get: `WARNING: The UID variable is not set. Defaulting to a blank string.` Should I set something else, somewhere? My docker-compose version is `1.5.0` – tunarob Nov 03 '15 at 23:16
  • I'd have thought that `user: $UID` will do the job not `user: ${UID}` which tells the container to evaluate the env variable within the container as opposed to `user: $UID` which interpolates it from the host. – WooDzu Nov 04 '15 at 06:46
  • @WooDzu both of those are actually equivalent, they're both evaluated on the host as part of the config loading. You have to set UID on the host for it to work. I think `user: $USER` would work – dnephin Nov 05 '15 at 21:10

1 Answers1

3

The instructions have now been updated and the next section has the solution: sudo chown -R $USER:$USER .

This happens because the user inside the container is root. You can set the user inside the container, but you'd have to create a new user with the same uid as your user on the host for the permissions/ownership to match. Setting the user via the "user" key as per @galozek's suggestion looks like it should also work, but this was added in 1.5 which was only released 15 hours ago (as I write)...

Adrian Mouat
  • 44,585
  • 16
  • 110
  • 102