How to install packages with miniconda in Dockerfile?
This will work using ARG and ENV:
FROM ubuntu:18.04
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN apt-get update
RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/*
RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
RUN conda --version
Related videos on Youtube
maciek
Updated on July 09, 2022Comments
-
maciek almost 2 years
I have a simple Dockerfile:
FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/* RUN wget \ https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ && mkdir /root/.conda \ && bash Miniconda3-latest-Linux-x86_64.sh -b \ && rm -f Miniconda3-latest-Linux-x86_64.sh \ && echo PATH="/root/miniconda3/bin":$PATH >> .bashrc \ && exec bash \ && conda --version RUN conda --version
And it cannot be built. At the very last step I get
/bin/sh: 1: conda: not found
....
The first appearance ofconda --version
did not raise an error which makes me wonder is that anPATH
problem?
I would like to have anotherRUN
entry in this Dockerfile in which I would install packages withconda install ...
At the end I want to haveCMD ["bash", "test.py"]
entry so that when in dodocker run
this image it automatically runs a simple python script that imports all the libraries installed with conda. Maybe also aCMD ["bash", "test.sh"]
script that would test if conda and python interpreter are indeed installed.This is a simplified example, there will be a lot of software so I do not want to change the base image.
-
cel over 4 yearssee also: stackoverflow.com/questions/57292146/…
-
-
Matheus Araujo over 2 yearsIf you get "/bin/sh: conda: command not found" is because you did not add the miniconda to your PATH. This is why you have to set the environment variables shown on the top of the snippet.
-
Howcanoe Wang over 2 yearsremove the brackets of {PATH}, change it to "/root/miniconda3/bin:$PATH" works on my device
-
Soren almost 2 yearsAnd then ? When I run
RUN conda activate
I getCommandNotFoundError: Your shell has not been properly configured to use 'conda activate'