Mount temporary conda channel during image build

Hi there !

I need some help here. I am trying to build an image that essentially builds a conda env inside the container. The way i have set-up my project looks like:

I have an inhouse conda channel that is mounted (samba) to my local machine

//SERVER/media/mnt/conda-channels   /mnt/opt/conda-channels

when i want to install something from it i justa specify the pathe and all works…

Next I have my project locally set up under:

/home/user/docker/wcd

my docker file looks like :

FROM continuumio/miniconda3:4.10.3p1
COPY ./src/ /opt/src/
RUN --mount=source=/mnt/opt/conda-chone/,type=bind,target=/mnt/    ls /mnt/ \
   && conda env create -f /opt/src/utils/conda/dimc.yml     
   && conda clean -afy \
   && find /opt/conda/ -follow -type f -name '*.a' -delete \
   && find /opt/conda/ -follow -type f -name '*.pyc' -delete \
   && find /opt/conda/ -follow -type f -name '*.js.map' -delete

WORKDIR /opt/mnt
ENV PATH /opt/conda/bin:/opt/.local/bin:$PATH

what i get when i try to build it:

 DOCKER_BUILDKIT=1 docker build --no-cache -t wcd:1.0.6 -f wcd.dockerfile .
#1 [internal] load build definition from wcd.dockerfile
#1 sha256:81262c97de76f2e6134831c793b66ce773420d5cce29b16905553147b77e2d91
#1 transferring dockerfile: 526B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:72cbd3724a72a86346cc3ccdaf34829ef87304b434e2d34254e3c1f5acd14720
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/continuumio/miniconda3:4.10.3p1
#3 sha256:ce132359fb6b26058aab75c696ef4334a659ca6933fd0640f7f9c10051f74e22
#3 DONE 1.1s

#4 [1/4] FROM docker.io/continuumio/miniconda3:4.10.3p1@sha256:569836b3f93ef06df731b3a917e58cc65c54f4ba87524f98c4753f99d5654026
#4 sha256:81a6755ad7b2adfcf9ffd832ada75d680ad4273926b3af313d941a2018df691e
#4 resolve docker.io/continuumio/miniconda3:4.10.3p1@sha256:569836b3f93ef06df731b3a917e58cc65c54f4ba87524f98c4753f99d5654026 done
#4 sha256:c256cb8a03f53bc258cce8c545ce0d4fd1f17cf695dfd11aa550f602a020e181 0B / 50.06MB 0.1s
#4 sha256:96470ebef4adc6521c81f93d2437e182de590faa6efdcc38a83484b502f46d6c 0B / 58.19MB 0.1s
#4 sha256:569836b3f93ef06df731b3a917e58cc65c54f4ba87524f98c4753f99d5654026 1.36kB / 1.36kB done
#4 sha256:1283ad2e67cd483de5123cefb25767a04521c48160da6099965e306224adfd54 953B / 953B done
#4 sha256:4d529c886124409ea8f150a4db1a2221a3ccda86fe5d6f4d555eee7ef7285645 4.08kB / 4.08kB done
#4 sha256:a2abf6c4d29d43a4bf9fbb769f524d0fb36a2edab49819c1bf3e76f409f953ea 0B / 31.36MB 0.1s
#4 CANCELED

#5 [internal] load build context
#5 sha256:29231f6e95f78d4c020e05f322596964aa88893de9fa8130ecbb21146b395303
#5 transferring context: 36.33MB 0.3s done
#5 DONE 0.3s

#6 [2/4] COPY ./src/ /opt/src/
#6 sha256:586ead68a0cd84aaeee0ecd97b1b943248a419920f4a93f4c79096d6848942a3
#6 CACHED

#7 [3/4] RUN --mount=source=/mnt/opt/conda-chone/,type=bind,target=/mnt/    ls /mnt/     && conda env create -f /opt/src/utils/conda/dimc.yml    && conda clean -afy    && find /opt/conda/ -follow -type f -name '*.a' -delete    && find /opt/conda/ -follow -type f -name '*.pyc' -delete    && find /opt/conda/ -follow -type f -name '*.js.map' -delete
#7 sha256:661b918f31a7c39ab85059bba8114810d30cf543e7c89d650695002f9ad50726
#7 ERROR: "/mnt/opt/conda-chone" not found: not found
------
 > [3/4] RUN --mount=source=/mnt/opt/conda-chone/,type=bind,target=/mnt/    ls /mnt/     && conda env create -f /opt/src/utils/conda/dimc.yml    && conda clean -afy    && find /opt/conda/ -follow -type f -name '*.a' -delete    && find /opt/conda/ -follow -type f -name '*.pyc' -delete    && find /opt/conda/ -follow -type f -name '*.js.map' -delete:
------
failed to compute cache key: "/mnt/opt/conda-chone" not found: not found

it seams i cannot see my mount point.

How to enable mount during the build that is not within my project directory and is mounted like i have it mounted here?

You can’t mount anything outside your build context as you can’t copy anything from outside your build context. / refers to your build context so /mnt/opt/conda-chone refers to <buildcontext>/mnt/opt/conda-chone and that folder does not exist.