Giter Club home page Giter Club logo

Comments (5)

nickjj avatar nickjj commented on May 26, 2024 1

This is fixed in: b269057

from docker-django-example.

nickjj avatar nickjj commented on May 26, 2024

Hi,

The containers run as a non-root user and Docker by default will bind mount files as uid/gid 1000:1000 when you set USER xxx in your Dockerfile with no other details.

Is your user not 1000? You can check by running id from your Docker host. I do run native Linux and have deployed this app on many Linux systems without issues on various VPSs since the first user you create on a Linux system will be 1000:1000 by default. No using of sudo should be needed.

from docker-django-example.

westbywest avatar westbywest commented on May 26, 2024

The active user running docker-compose having uid 1000 won't be guaranteed. Mine is 1001 due to presence of other local users, and similar for systems with centralized user management like via LDAP. For an active user with uid != 1000 to chown something to that id, sudo is required.

Recommendation is to add mention of default uid.gid = 1000:1000 to the README, and Linux users with different ids need to update Dockerfile with USER xxx or chown 1000 {public,public_collected}.

from docker-django-example.

nickjj avatar nickjj commented on May 26, 2024

You are correct in that it's not guaranteed, but it is the default behavior of Docker.

If you chown those directories as 1000, chances are your 1001 user won't have write access to those directories and you'll end up with the same permission denied error. Basically this ends up being very system specific but works out of the box 98% of the time. I wish I had a better answer but Docker doesn't make this process any more portable and the benefits of running things as a non-root user vastly out weigh having everything owned by root.

from docker-django-example.

nickjj avatar nickjj commented on May 26, 2024

Hey, I know it's been a while but can you try out this PR and report back whether it works or not in that PR? nickjj/docker-flask-example#7

It should be a generic solution that will let you run things without permission errors by customizing the UID and GID in the .env file if your user account isn't set to 1000:1000.

I know it's a Flask app and not Django but I can port the same change over to this Django example app if it works.

from docker-django-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.