-
Notifications
You must be signed in to change notification settings - Fork 283
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
Can not use conda command as non root user. #151
Comments
Also environments are now stored in |
I think the problem is that the package cache writability check succeeds for one file, but not for all files. See https://github.com/conda/conda/blob/master/conda/core/package_cache_data.py#L147-L165 The default pkgs_dirs setting is here: https://github.com/conda/conda/blob/master/conda/base/context.py#L461-L473 It appears to me that the real problem is that the fallback to ~/.conda is failing. I don't know why. Maybe you need to check and set permissions on /home/ubuntu? |
Scratch that. I'm pretty sure it's this: conda/conda#9215 It'll be fixed in conda 4.7.12. |
What are the impacted versions? @cpaulik was using latest tag. |
This might be a dumb question, but what is the purpose of forcing a non-root user? I'm sure there's a good reason that I'm missing, but it seems odd to me. I don't expect my base images to be hardened and I use miniconda3 as a base image where I build other stuff. Being forced to use a non-root user makes that more difficult since I need to use a multi-stage build and copy from the miniconda3 container rather than just using the miniconda3 container directly. |
Best practices, safety first, beter safe than sorry, etc.
EDIT: But yeah. It's a bit of a pain with multistage builds. |
Our reason is that the containers mount a NFS. And since they all read and write there it is handy to have the same UID, GID. There are probably better ways to do this but this is what we are using at the moment. |
Maybe an intermediate target could be added and built as a separate image before the user gets switched to root? I this this may force me to maintain my own conda image in the future otherwise, which is something I'd prefer not to do since it is generally more secure and faster to use official images. |
I have been trying older docker images, to work around this, and this issue seems to have cropped up sometime after tag 4.6.14. Here is a working Dockerfile in case it's helpful for anyone:
|
This seems to work with 4.7.12; though I'm not sure that it's all necessary? FROM continuumio/miniconda3:4.7.12
# ...
RUN adduser --disabled-password --gecos "Default user" --uid 1000 cq
RUN mkdir /opt/conda/envs/cq /opt/conda/pkgs && \
chgrp cq /opt/conda/pkgs && \
chmod g+w /opt/conda/pkgs && \
touch /opt/conda/pkgs/urls.txt && \
chown cq /opt/conda/envs/cq /opt/conda/pkgs/urls.txt
COPY --chown=cq:cq environment.yml labextensions.txt /opt/conda/envs/cq/
WORKDIR /home/cq
USER cq
RUN conda env create -f /opt/conda/envs/cq/environment.yml -n cq && \
conda run -n cq conda install -y nodejs (This is adapted from https://github.com/bernhard-42/jupyter-cadquery/blob/master/docker/Dockerfile ) |
... Allowing the 'cq' user / group to modify |
JFYI: For me @guidorice solution with the older version |
@guidorice I did the same: stick to
|
I had this same issue and it smells like a bit of a bug (or maybe this is intentional for some reason I'm not aware of). I'm running
If I create a
then inside the container I run:
it shows:
so although the user's local envs_dir takes precedence over
|
How is this similar or different to "CWE-427: Uncontrolled Search Path Element" |
This is still an issue as of miniconda 4.9.2 (currently latest tag on docker hub): docker run -it --rm continuumio/miniconda3 sh
(manually creating the directory Upgrading to 4.10.1 appears to fix this issue: docker run -it --rm continuumio/miniconda3 sh
Will 4.10.1 image be published on docker hub any time soon? |
This is still a problem with continuumio/anaconda3:2021.05 |
It would be good if this Docker image could do something like create a conda group with the correct permissions to the relevant conda directories, and then when using the image you just have to create a user and assign the conda group and it automatically gets the required permissions. (also adding documentation to tells users this) |
Could that be in the entrypoint script with a file-based lock so that the
initial configuration (maybe from documented env vars that there may
already be conventions for) is idempotent?
…On Tue, Jul 27, 2021, 19:39 Reuben Turk ***@***.***> wrote:
It would be good if this Docker image could do something like create a
conda group with the correct permissions to the relevant conda directories,
and then when using the image you just have to create a user and assign the
conda group and it automatically gets the required permissions. (also
adding documentation to tells users this)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#151 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMNSZBSASRJXTML4K53VTTZ47RPANCNFSM4IWGMQQQ>
.
|
No, setting initial file permissions really belongs to the Dockerfile. The entry point script does not necessarily run as root. It can be the last Today I figured out the problem is not permissions, but simply missing docker run -it --rm continuumio/miniconda3:4.10.3 bash In container: useradd -s /bin/bash -m ana
su -c 'conda info' ana
This fails: su -c 'conda create -n foo' ana
But the problem is not that user mkdir /opt/conda/pkgs
touch /opt/conda/pkgs/urls.txt
su -c 'conda create -n foo' ana
|
Yup, then end users would need to rebuild the container image in order to change the uid/username. If the entrypoint script is not running as uid 0, don't try to |
I don't understand. Change the uid of what? I want conda to work out of the box for a regular user. There's no reason to give a regular user write access somewhere outside their home. |
Which parts of conda can/should be owned by any of eg. these roles?
|
Running
conda
as another user than root does not seem to work anymore with the latest images.This used to work fine with older images
The dockerfile:
give the following error when running
docker build -f Dockerfile .
The text was updated successfully, but these errors were encountered: