repo2docker icon indicating copy to clipboard operation
repo2docker copied to clipboard

when building a non-Dockerfile x86 image on apple silicon (M1, M2, M2 Pro),`repo2docker` fails on `mamba env update`

Open shaneknapp opened this issue 1 year ago • 3 comments

Bug description

repo2docker fails when a non-Dockerfile build hits the following step:

Step 40/53 : RUN TIMEFORMAT='time: %3R' bash -c 'time ${MAMBA_EXE} env update -p ${NB_PYTHON_PREFIX} --file "environment.yml" && time ${MAMBA_EXE} clean --all -f -y && ${MAMBA_EXE} list -p ${NB_PYTHON_PREFIX} '
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 35f6725e11e1

CondaError: Error encountered while attempting to create cache directory.
  Directory: /home/sknapp/.cache/conda/notices
  Exception: [Errno 13] Permission denied: '/home/sknapp/.cache/conda'

time: 0.407

the commands i tried were:

  1. repo2docker --user-id 501 --no-run --Repo2Docker.platform=linux/amd64 --Repo2Docker.base_image=docker.io/library/buildpack-deps:jammy .
  2. repo2docker --no-run --Repo2Docker.platform=linux/amd64 --Repo2Docker.base_image=docker.io/library/buildpack-deps:jammy .
  3. repo2docker --user-id 1000 --no-run --Repo2Docker.platform=linux/amd64 --Repo2Docker.base_image=docker.io/library/buildpack-deps:jammy .

the image that failed to build: https://github.com/berkeley-dsep-infra/datahub/tree/staging/deployments/data100/image

however, if you build an image that's based on a Dockerfile, you're good to go! you can try yourself with this image: https://github.com/berkeley-dsep-infra/datahub/tree/staging/deployments/dev/images/default

it appears that repo2docker might not be inheriting or passing on the correct permissions to allow writing to the local filesystem during the mamba env update step.

Expected behaviour

i would expect mamba to be able to update the conda env. :)

Actual behaviour

it fails.

How to reproduce

  1. get a mac w/an M chip, and run repo2docker --user-id 1000 --no-run --Repo2Docker.platform=linux/amd64 --Repo2Docker.base_image=docker.io/library/buildpack-deps:jammy . on an image dir that doesn't have a Dockerfile
  2. fail!

Your personal set up

  • OS: OSX sonoma
  • Docker version: 26.1.1
  • repo2docker version: 2024.03.0

shaneknapp avatar May 29 '24 22:05 shaneknapp

I found a workaround for this by specifying --target-repo-dir like so:

jupyter-repo2docker --user-id=1000 --user-name=jovyan --Repo2Docker.platform=linux/amd64 --target-repo-dir=/home/jovyan/.cache .

Looking at issue #1334 my theory was this would create the necessary directory with the necessary perms, and it does!

felder avatar Jun 11 '24 23:06 felder

Is this still a problem with the latest main branch? I suspect it might be a Docker bug rather than anything in r2d.

manics avatar Sep 16 '24 15:09 manics

@manics The workaround mostly works, but it seems like it wouldn't be the expected behavior.

felder avatar Sep 17 '24 22:09 felder