簡體   English   中英

使用 Docker 激活 conda 時出現 CommandNotFoundError

[英]CommandNotFoundError when activate conda with Docker

我是Docker的新手,並嘗試通過激活conda環境來構建Docker映像。 但我不能。

這是我的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"]

我的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

當我構建圖像docker build -t condatest. ,我得到這個錯誤:

...
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'.

你們知道我錯在哪里嗎?

RUN conda activate FM不做任何事情,因為它只在那個特定的RUN中激活。 它對以后的RUNENTRYPOINT/CMD命令沒有影響。

這也是不必要的,因為您在入口點中使用 conda conda run並使用SHELL來啟用環境 ala https://pythonspeed.com/articles/activate-conda-dockerfile/

忽略它,你會沒事的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM