【发布时间】:2022-07-24 12:52:36
【问题描述】:
我想在 docker 容器中合并一个虚拟环境,因此我正在尝试创建一个 Conda 环境(第 117-128 行),其中包含我的用例所需的必要依赖项,该依赖项位于 environment.yml 文件中。但是,当我尝试构建 Dockerfile 时,我遇到了标题中提到的以下问题。
https://gist.github.com/impaidk/504363033b34406367e774c72544c540
Dockerfile 可以在上面的链接中找到。
添加第 117 到 128 行后,我遇到了这个问题。 在添加这些行之前,我可以成功构建 docker 文件。有人可以指导我在这里做错了什么吗?
Removing intermediate container 426298ea76b6
---> 68c8b7342cc2
Step 36/54 : RUN echo "conda activate env_vis2mesh" >> ~/.bashrc
---> Running in 53949a223622
Removing intermediate container 53949a223622
---> 7635492d073b
Step 37/54 : SHELL ["/bin/bash", "--login", "-c"]
---> Running in 992f511d7842
Removing intermediate container 992f511d7842
---> aafcba711b55
Step 38/54 : RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && ( echo "cat <<EOF" ; cat /etc/motd ; echo EOF ) | sh' >> /etc/bash.bashrc
---> Running in 0ff2bb34ea36
Removing intermediate container 0ff2bb34ea36
---> 643f0f83bbd5
Step 39/54 : COPY motd /etc/
---> d10c760f8d25
Step 40/54 : USER $DOCKER_USER
---> Running in 9cc835cbdebb
Removing intermediate container 9cc835cbdebb
---> 819fae915c5f
Step 41/54 : RUN echo "umask 002" >> $DOCKER_HOME/.bashrc
---> Running in 9a24755e10ab
Removing intermediate container 9a24755e10ab
---> 5acb97493c3d
Step 42/54 : RUN echo "source $DOCKER_HOME/.version_information.sh" >> $DOCKER_HOME/.bashrc
---> Running in affb5a5086b1
Removing intermediate container affb5a5086b1
---> 101f71c5c403
Step 43/54 : COPY .version_information.sh $DOCKER_HOME
---> bc0bdd3b2437
Step 44/54 : RUN echo "if [[ -f $DOCKER_HOME/.bashrc-appendix ]]; then source $DOCKER_HOME/.bashrc-appendix; fi" >> $DOCKER_HOME/.bashrc
---> Running in badd158a5c1f
Removing intermediate container badd158a5c1f
---> cd42c89e893c
Step 45/54 : RUN mkdir -p $DOCKER_MOUNT_DIR/src
---> Running in 92dceb96a5f8
Removing intermediate container 92dceb96a5f8
---> d702d73b89f0
Step 46/54 : RUN mkdir $DOCKER_HOME/.ssh
---> Running in 463b4c55314b
Removing intermediate container 463b4c55314b
---> 49bc41c8e310
Step 47/54 : ADD templates $DOCKER_HOME/templates
---> d62e67ea2fc5
Step 48/54 : RUN echo 'export PATH=$PATH:$DOCKER_HOME/templates/bin' >> $DOCKER_HOME/.bashrc # using single quotes ensures that $PATH is not replaced here
---> Running in aee1b4ca57d9
Removing intermediate container aee1b4ca57d9
---> e119faed304a
Step 49/54 : USER root
---> Running in acc1ca160be5
Removing intermediate container acc1ca160be5
---> 6f3130f1a9a1
Step 50/54 : WORKDIR $DOCKER_MOUNT_DIR
cannot normalize nothing
【问题讨论】:
-
当您进入多阶段 Dockerfile 中的新阶段时,环境变量不会被保留。您需要在 Dockerfile 的最后部分再次设置它们 - 或对工作目录进行硬编码。
-
请编辑问题以包含重现问题所需的信息在问题本身中,而不是在链接后面。看看你给出的输出,我注意到你通常可以安全地硬编码细节,比如将被编译到图像中的用户名和路径,并且像
.bashrc这样的 shell 点文件通常不用于完全是 Docker(docker run image some-command将忽略.bashrc)。
标签: docker dockerfile