Comments (7)
Hi,
Which environment are you running where this is an issue?
So far I've tested this on a bunch of Windows DD, macOS DD and native Linux systems and it's been ok.
Are you running native Linux where your host user isn't 1000:1000
? I could see that being an issue, but usually you're in control of being able to set your uid:gid
on a native Linux dev box. In production it's usually not an issue since you wouldn't be using volumes, but on a self managed box typically you'd have control over your uid:gid
if you did need them for whatever reason.
It's a tricky one to solve because the Node stage has a node
user already created by the official image with a hardcoded 1000
for the uid:gid
so we'd run into the issue there unless a 2nd user were to be created.
from docker-flask-example.
Are you running native Linux where your host user isn't
1000:1000
Yep. My uid:gid
is 1001 in my machine.
I could see that being an issue, but usually you're in control of being able to set your
uid:gid
on a native Linux dev box or self managed VPS.
Well.. it's not that straight forward, since you have to log-out from that user and change the uid
by being root and with no process currently being run by that user.. so it's requires some work.
`hardcoded 1000 for the uid:gid so we'd run into the issue there unless a 2nd user were to be created.
Well.. you can always set the user
flag and start the container with that gid
even though the user doesn't exist on the system. I recall seeing some docker run -u "$(id -u)"
exactly for this permission issue.
from docker-flask-example.
What happens if you add this line to the x-app: &default-app
list of properties in docker-compose.yml
as well as the webpack
service in docker-compose.override.yml
:
user: "${UID:-1000}:${GID:-1000}"
Then in your .env
file, add these 2 lines:
export UID=1001
export GID=1001
This would bypass having to change the Dockerfile
. It's working on my machine here with 1000:1000
and if I change those .env
vars to 1001:1001
then I get a permission denied error which makes sense since I don't have a user with 1001 here.
from docker-flask-example.
And potentially even better, if you already have UID
and GID
available in your shell then you don't need to override the .env
file, it should work out of the box. I believe on most Linux systems and shells those env vars should be set?
Can you try in both cases? One where you don't set the custom vars in .env
and another case where you do? The shell version should take priority so I guess in theory if it's already set in your shell then whatever you put in .env
will get ignored anyways.
from docker-flask-example.
Nope, this doesn't work and it makes sense on why it doesn't work. I tried it out with a 2nd user on my system.
I mean it technically works in the sense permissions would be correct but the containers don't run because package dependencies have been installed with the 1000:1000
user at build time and setting user: "1001:1001"
at runtime is much more than adjusting volume permissions. The container is being run as that user who has no knowledge of those dependencies because they've been installed as 1000:1000
.
Also in the case of the Node stage in this project, there's an explicit chown
in the Dockerfile
to ensure the 1000:1000
user has write access to /node_modules
, but 1001:1001
won't have write access there so you get permission denied. This happened when Tailwind tried to write a file at runtime to somewhere in /node_modules
.
from docker-flask-example.
Hey I know it's been a while but there's a potential fix for this issue in #7.
Can you please try out that PR and let me know how it goes? All you'd have to do before building and upping the project is modify the .env
file to use UID=1001
and GID=1001
(there's existing values commented out in the .env.example
file). You should be able to build and up the project without permission issues.
from docker-flask-example.
I ended up merging #7 which should fix this.
from docker-flask-example.
Related Issues (14)
- Celery stuff HOT 4
- unbound variable on macos ventura HOT 2
- Error when doing docker compose HOT 4
- remove asset in .env file and request is slowly HOT 2
- Frontend folder creation permissions issue HOT 20
- Flask / Werkzeug 3.0 and Python 3.12 updates HOT 3
- models usage HOT 1
- cannot create directory ‘public/js’: Permission denied - Rootless docker HOT 12
- In file ./.env: environment variable name 'export COMPOSE_PROJECT_NAME' may not contain whitespace. HOT 2
- Issues running in production executing the application HOT 4
- assistance understanding assets and es build in production HOT 17
- Getting Error with docker compose => ERROR [helloflask_web app 6/9] RUN chmod 0755 bin/* && bin/pip3-install HOT 11
- Tips on deploying HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-flask-example.