简体   繁体   中英

docker-compose creates file owned by root

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?

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)...

Here's a container pattern for assigning the userid / groupid at runtime in a way that's easily portable. https://github.com/Graham42/mapped-uid-docker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM