[英]CommandNotFoundError when activate conda with Docker
I am new to Docker
and try to build the Docker
image with the activation of the conda
environment.我是
Docker
的新手,并尝试通过激活conda
环境来构建Docker
映像。 But I can't.但我不能。
This is my Dockerfile
:这是我的
Dockerfile
:
FROM continuumio/miniconda3
COPY . /app
WORKDIR /app
RUN conda env create -f environment.yml
SHELL ["conda", "run", "-n", "FM", "/bin/bash", "-c"]
RUN conda activate FM
ENTRYPOINT ["conda", "run", "-n", "FM", "python", "src/run.py"]
My environment.yml
file:我的
environment.yml
文件:
name: FM
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- ca-certificates=2020.6.24=0
- certifi=2020.6.20=py37_0
- ld_impl_linux-64=2.33.1=h53a641e_7
- libedit=3.1.20191231=h7b6447c_0
- libffi=3.2.1=hd88cf55_4
- libgcc-ng=9.1.0=hdf63c60_0
- libstdcxx-ng=9.1.0=hdf63c60_0
- ncurses=6.2=he6710b0_1
- openssl=1.1.1g=h7b6447c_0
- pip=20.1.1=py37_1
- python=3.7.6=h0371630_2
...
- pip:
- click==7.1.2
- cycler==0.10.0
- decorator==4.4.2
- flask==1.1.2
- imageio==2.9.0
- itsdangerous==1.1.0
...
prefix: /home/huytran/miniconda3/envs/FM
When I build the image docker build -t condatest.
当我构建图像
docker build -t condatest.
, I get this error: ,我得到这个错误:
...
Step 5/8 : SHELL ["conda", "run", "-n", "FM", "/bin/bash", "-c"]
---> Running in 962623c513cc
Removing intermediate container 962623c513cc
---> c5a91349830f
Step 6/8 : RUN conda activate FM
---> Running in 1f3d1cd0c50b
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Do you guys know where I am wrong?你们知道我错在哪里吗?
The RUN conda activate FM
doesn't do anything, because it only activates in that particular RUN
. RUN conda activate FM
不做任何事情,因为它只在那个特定的RUN
中激活。 It has no impact on future RUN
or ENTRYPOINT/CMD
commands.它对以后的
RUN
或ENTRYPOINT/CMD
命令没有影响。
It's also unnecessary, since you're using conda run
in the entrypoint and using the SHELL
to enable the environment ala https://pythonspeed.com/articles/activate-conda-dockerfile/ .这也是不必要的,因为您在入口点中使用 conda
conda run
并使用SHELL
来启用环境 ala https://pythonspeed.com/articles/activate-conda-dockerfile/ 。
Just omit it and you'll be fine.忽略它,你会没事的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.