-
Notifications
You must be signed in to change notification settings - Fork 46
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
Cache accessing error when creating environments in containers from a derived image with host uid. #445
Comments
Maybe related: My wild guess is that there are cached files from the micromamba processes in the default Dockerfile that you cannot access or modify due to the user id or group mismatch. Edit: On which platform are you running this? There are quite some differences in Linux vs. Docker Desktop on OSX due to the different ways of managing volumes from the host to the container. |
@mfhepp Thank you for the reply. I found the difference between using derived image and the original image, exactly "the user id or group mismatch". It could be the reason for the different behaviors. The derived image installs packages into base environment, and micromamba creates directory When using original image, there are no directories named |
FYI: A write-up of lessons learned with mounting local volumes in Docker is in the docs of my py4docker project, which is based on https://github.com/mfhepp/py4docker?tab=readme-ov-file#user-id-mismatch-problems-on-linux For analyzing the root cause of your problem, it may be best to try the following steps (a bit sketchy, may contain minor syntactical bugs ;-) ):
UID_HOST=$(id -u)
GID_HOST=$(id -g)
echo "INFO: Local User has UID = $UID_HOST, GID = $GID_HOST" For instance, Docker Desktop on OSX (and maybe other OSs) does not pass UIDs < 1000 to the container user.*
FROM mambaorg/micromamba:1.5.7
ARG MAMBA_DOCKERFILE_ACTIVATE=1
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/bin/sh"] docker run -it -v $(pwd)/cache:/data -u $(id -u):$(id -g) --rm testmamba
# inside the container
id -u
id -g
# or simply
id
ls -lah /opt/conda/pkgs/ You will see the permissions for all relevant files and folders.
# inside the container
micromamba install -y -n base python=3.12 -c conda-forge With these steps, it should be possible to find the exact cause of your problem. As said, you are most likely not able to read or change files from the base |
One more thing: Did you try to put the Like so: FROM mambaorg/micromamba:1.5.7
RUN micromamba install -y -n base python=3.12 -c conda-forge && \
micromamba clean --all --yes
ARG MAMBA_DOCKERFILE_ACTIVATE=1 |
@StardustDL Good! If this fixes the problem, can we close this issue? |
Thanks for your detailed notes! It really helps. I would close this issue. Leave some notes about the debug process, that could help others. The host uid and gid both are 1000, and through When using following dockerfile, FROM mambaorg/micromamba:1.5.7
ARG MAMBA_DOCKERFILE_ACTIVATE=1
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/bin/bash"] Then introduce the FROM mambaorg/micromamba:1.5.7
ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN micromamba install -y -n base python=3.12 -c conda-forge && \
micromamba clean --all --yes
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/bin/bash"] Then there are many files under (base) I have no name!@8a11ae12ddfb:/tmp$ ls /opt/conda -lha
drwxr-xr-x 2 mambauser mambauser 4.0K Mar 13 06:38 bin
drwxrwxrwx 1 root root 4.0K Mar 13 06:38 conda-meta
drwxr-xr-x 10 mambauser mambauser 4.0K Mar 13 06:38 include
drwxr-xr-x 14 mambauser mambauser 4.0K Mar 13 06:38 lib
drwxr-xr-x 26 mambauser mambauser 4.0K Mar 13 06:38 pkgs
.... omited
(base) I have no name!@8a11ae12ddfb:/tmp$ ls /opt/conda/pkgs -lha
total 112K
drwxr-xr-x 26 mambauser mambauser 4.0K Mar 13 06:38 .
drwxr-xr-x 7 mambauser mambauser 4.0K Mar 13 06:38 bzip2-1.0.8-hd590300_5
.... omited There are two permission errors (collected by
|
Did you try to put the FROM mambaorg/micromamba:1.5.7
RUN micromamba install -y -n base python=3.12 -c conda-forge && \
micromamba clean --all --yes
ARG MAMBA_DOCKERFILE_ACTIVATE=1
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/bin/bash"] |
@mfhepp Yes, but no changes happened. (base) I have no name!@215ad28b8f1b:/tmp$ micromamba create -n p python=3.12 -c conda-forge -y
conda-forge/linux-64 ..... 12.0MB / 33.0MB @ 4.4MB/s 2.9s
critical libmamba Multiple errors occured:
Non-writable cache error.
Subdir conda-forge/noarch not loaded! |
Did you build the image with For others who end up here: _dockerfile_shell.sh is the script that is run when a
It is clear that this may lead to all kinds of conflicts if there are permission or username mismatches. To be frank, I do not fully understand the interplay between For debugging, one may want to inspect the status of RUN echo ${MAMBA_DOCKERFILE_ACTIVATE} Note: If any effects of such problems those are frozen in cached build stages, they will be very difficult to debug. See also #443 It will also be helpful to run a container with an interactive terminal and use the # Do this inside the container via an interactive terminal
env The output will look similar to this: CONDA_PROMPT_MODIFIER=(base)
MAMBA_USER_GID=57439
USER=mambauser
HOSTNAME=...redacted...
ENV_NAME=base
SHLVL=0
HOME=/home/mambauser
CONDA_SHLVL=1
MAMBA_USER=mambauser
MAMBA_USER_ID=57439
TERM=xterm
PATH=/opt/conda/bin:/opt/conda/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAMBA_ROOT_PREFIX=/opt/conda
LANG=C.UTF-8
CONDA_DEFAULT_ENV=base
MAMBA_EXE=/bin/micromamba
PWD=...your path...
LC_ALL=C.UTF-8
CONDA_PREFIX=/opt/conda /CC @wholtz |
I have rebuilt using |
I may have misunderstood what you want to achieve, actually. The normal way of using Now, creating new environments inside the container is to my understanding not really supported by But creating new environments from within the running container is calling for trouble, see e.g. details. You may be able to get that to work by disabling auto-activation, like so: docker run --rm -it -e MAMBA_SKIP_ACTIVATE=1 testmamba bash But with your approach, you are interfering pretty deeply with how Sorry that I misunderstood this; I hope this lengthy discussion is useful for others nonetheless. |
Hello, I encounter an error about cache when creating new environments in the container if I use the host user.
I want to mount a directory to the container, so I followed #407 to use
-u $(id -u):$(id -g)
option indocker run
.I'm using the following Dockerfile and build the image by
docker build . -t testmamba
.Then when I run
micromamba create
in the container,Non-writable cache error
occurs.A little confusing case, everything works fine when I use
mambaorg/micromamba:1.5.7
image directly, not the derived image.If removing
micromamba clean --all --yes
in the dockerfile, the environment creation will be completed although some error occurs.If running the container without
-u $(id -u):$(id -g)
, then any writing to the mount directory getsPermission denied
.Using
-u root
works fine, but I want to know if there are any solutions for non-root containers?Updated:
Platform and Docker versions, copied from
docker info
:The text was updated successfully, but these errors were encountered: