Dockerfile使用ENV指令中的$ PATH运行bash文件

时间:2021-09-13 23:14:16

Bellowing are part of my Dockerfile, I want to set PATH once with ENV, and in the following *.sh file, they don't need to re-define the $PATH. How to achieve this ?

Bellowing是我的Dockerfile的一部分,我想用ENV设置一次PATH,在下面的* .sh文件中,它们不需要重新定义$ PATH。怎么做到这一点?

ENV PATH="/usr/local/bin:/opt/local/sbin:$PATH"

RUN /bin/bash -c "source install_anaconda3.sh"

RUN /bin/bash -c "source install_tensorflow.sh"

RUN /bin/bash -c "source install_theano.sh"

Inside install_anaconda3.sh it is:

在install_anaconda3.sh里面是:

#!/bin/bash -
bash "./installer/Anaconda3-5.0.1-Linux-x86_64.sh" -u -b

conda upgrade -y --all

Then I got following error:

然后我得到以下错误:

/bin/sh: install_anaconda3.sh: command not found

/ bin / sh:install_anaconda3.sh:找不到命令

2 个解决方案

#1


0  

@Pavel Agarkov, I changed to

@Pavel Agarkov,我换了

RUN export CUDA_HOME=/usr/local/cuda

RUN导出CUDA_HOME = / usr / local / cuda

RUN export PATH="/root/anaconda3/bin:$PATH"

RUN导出PATH =“/ root / anaconda3 / bin:$ PATH”

RUN export PATH="/usr/local/bin:/opt/local/sbin:$PATH"

RUN导出PATH =“/ usr / local / bin:/ opt / local / sbin:$ PATH”

RUN /bin/bash -c "source install_anaconda3.sh" while in install_anaconda3.sh, it still could not get the correct PATH.

在install_anaconda3.sh中运行RUN / bin / bash -c“source install_anaconda3.sh”时,它仍然无法获得正确的PATH。

#2


0  

You can set a working directory so the following commands will be running in its context:

您可以设置工作目录,以便在其上下文中运行以下命令:

WORKDIR /usr/local/bin
# run scripts from /usr/local/bin
RUN ./install_anaconda3.sh
RUN ./install_tensorflow.sh
# ...

This way you don't need $PATH

这样你就不需要$ PATH了

#1


0  

@Pavel Agarkov, I changed to

@Pavel Agarkov,我换了

RUN export CUDA_HOME=/usr/local/cuda

RUN导出CUDA_HOME = / usr / local / cuda

RUN export PATH="/root/anaconda3/bin:$PATH"

RUN导出PATH =“/ root / anaconda3 / bin:$ PATH”

RUN export PATH="/usr/local/bin:/opt/local/sbin:$PATH"

RUN导出PATH =“/ usr / local / bin:/ opt / local / sbin:$ PATH”

RUN /bin/bash -c "source install_anaconda3.sh" while in install_anaconda3.sh, it still could not get the correct PATH.

在install_anaconda3.sh中运行RUN / bin / bash -c“source install_anaconda3.sh”时,它仍然无法获得正确的PATH。

#2


0  

You can set a working directory so the following commands will be running in its context:

您可以设置工作目录,以便在其上下文中运行以下命令:

WORKDIR /usr/local/bin
# run scripts from /usr/local/bin
RUN ./install_anaconda3.sh
RUN ./install_tensorflow.sh
# ...

This way you don't need $PATH

这样你就不需要$ PATH了