-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Run Docker container with a specific user #5556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Once this gets merged, we can just pull the docker image from Docker Hub and run our instance without doing additional steps.
No problems with messed permissions or owners of the files, etc. |
d14f9a3
to
2e29b61
Compare
This line can be added to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be added to settings/dev.py if you consider it's better, to avoid this extra step of adding it to the local settings file.
I'm +1 with this
@ericholscher tested this in MacOS and he said it worked properly. After some discussion I tested different versions of Python (installed via pyenv) in the Docker image and they worked. Although, when I tested a build with
So, when running the Docker container with a user that has a different UID:GID which does not have write permissions on at least one of those directories listed, we have a problem and the build fails.
I'm not sure yet how to solve this, but it may need changes on the |
A simple way to reproduce the issue locally for this,
The way I think this can be done is by setting a different paths with |
We said that we can still merge this and promote this to start contributing and alert the developer that If the developer wants to test a |
We should check that conda works in production :) |
Comment from the peanut gallery: I never saw the need to use conda inside Docker (as long as you have permission to install or compile any system dependency, of course) |
@Juanlu001 we use docker to encapsulate each build in production, we use docker in dev for testing and it's easy instead of installing all the stuff |
Pass --user (`DOCKER_USER`) attribute when creating the container. This has no effect in production since we are using the same user and group than the one defined inside the Dockerfile image (docs:docs). Although, this allow us to avoid permissions conflicts when running the build with Docker locally (development) since we can pass our current user. That way, every file created/modified inside the container will be done using the current UID and GID defined by the developer. This can be done as, local_settings.py DOCKER_USER = f'{os.geteuid()}:{os.getegid()}' With this change, there is no need to re-build the Docker image used in production with our own custom `USER` instruction. https://docs.docker.com/engine/reference/run/#user Co-authored-by: Raúl Cumplido <[email protected]>
This default value will make docker build image to work without worrying about user permissions.
e3df091
to
52ab399
Compare
I added a warning note under the "Build Environments" page that follows the "Installation" guide mentioning that in case that you need to build projects with Conda you may need to follow another guide to re-build our Docker image. I think it covers all the cases:
Being 1) and 2) most of the cases I'm happy to deploy this. Since 3) is a special and uncommon case, we can attend it separately and keep working on @agjohnson's PR #4608 with more time. |
Perhaps we should just work on merging #4608, if we can avoid breaking conda testing on linux installs -- given this impacts 3/5 of the core team. |
I'm probably -1 on this PR given it introduces a big blind spot for local conda testing. I think #4608 is closest to a working solution. I'm going to block this while we discuss the other PR more. |
Well, it is not a blind spot since it hard fail the builds with a permission error. IMO, asking contributors to build their own Docker image to fix a small issue adds a big barrier which probably makes to loose the contribution. Which is not a good. |
I want both.
I see this as a very easy way to start contributing. Then, if you find that your builds are failing, you will refer to the documentation and will find out the solution: re build your Docker image. Although, from the first build (and contribution) to a failing build because with conda, we could already received many contributors and ease their lives :) |
I'm +1 in just merging #4608, having a blind spot can cause surprises, and this failing with conda makes me think there are more things that could break? And, most of the contributors don't use docker, they use the local builder. |
I know you probably don't care too much about my point of view. As a new contributor having a docker environment with docker-compose being able to do |
@raulcd that's a different problem, using docker-compose or dockerize the project. This is about running the builds inside docker vs running the builds in the local machine. Current installation instructions should work without caring so much about where the builds happen. |
@humitos sorry, i meant it introduces a feature/section of code that won't be testable by contributors. we get an error, but you need to have the background in that error to know this is an issue with docker permissions.
I sort of agree there and understand that this PR is probably okay in a good chunk of cases, but the main thing I don't like is that conda just breaks. Contributors besides us won't know that the conda error is really a docker permission error because the image needs to be rebuilt. Reducing the areas where dev and prod differ is one of our short term goals, so this seems to move in the opposite direction. The good news is that the process for building an image on top of |
We can spend some time to make the original Docker image to install conda properly (defining PATHs properly) so it does not break. Then, keep using the code from this PR. That's probably the best direction to take since there won't be needed to rebuild the image. |
True, but I'd rather not invest more time in this right now though. Given our decision to deprioritize pointing new contributors at this code base, I don't think we need to further increase our focus on the new contributor here. For now, working with docker is going to be a prohibitively large hurdle either way, and we'll have a solution that works for 100% of contributors working at this level (with docker) without any further work. In the future, we can revisit this PR and make improvements to docker onboarding if we decide we want to prioritize getting contributions to our main product repo. |
I was trying to build docs using |
Yes I have followed this at first but was still getting permission denied |
I'm closing this PR in favor of #6295 which already include the commits from this PR. Thank you all for the help on this. Appreciated! |
Pass --user (
DOCKER_USER
) attribute when creating the container.This has no effect in production since we are using the same user and
group than the one defined inside the Dockerfile image (docs:docs).
Although, this allow us to avoid permissions conflicts when running
the build with Docker locally (development) since we can pass our
current user.
That way, every file created/modified inside the container will be
done using the current UID and GID defined by the developer.
This can be done as,
With this change, there is no need to re-build the Docker image used
in production with our own custom
USER
instruction.https://docs.docker.com/engine/reference/run/#user
@raulcd helped me to find out this and make it work properly considering production and development environment
Connected to #4608
Related #2692 #3245 #3003 #3152 #1133