How to install packages with miniconda in Dockerfile?(如何在 Dockerfile 中安装带有 miniconda 的软件包?)
问题描述
我有一个简单的 Dockerfile:
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
而且它不能被建造.在最后一步,我得到 /bin/sh: 1: conda: not found....conda --version 的第一次出现并没有引发错误,这让我想知道是 PATH 问题吗?
我想在这个 Dockerfile 中有另一个 RUN 条目,我将在其中安装带有 conda install ...
的软件包最后我想要 CMD ["bash", "test.py"] 条目,以便在执行 docker run 这个图像时它会自动运行一个简单的 python 脚本导入所有使用 conda 安装的库.也许还有一个 CMD ["bash", "test.sh"] 脚本来测试是否确实安装了 conda 和 python 解释器.
And it cannot be built. At the very last step I get /bin/sh: 1: conda: not found....
The first appearance of conda --version did not raise an error which makes me wonder is that an PATH problem?
I would like to have another RUN entry in this Dockerfile in which I would install packages with conda install ...
At the end I want to have CMD ["bash", "test.py"] entry so that when in do docker run this image it automatically runs a simple python script that imports all the libraries installed with conda. Maybe also a CMD ["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.
推荐答案
这将使用 ARG 和 ENV:
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
这篇关于如何在 Dockerfile 中安装带有 miniconda 的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Dockerfile 中安装带有 miniconda 的软件包?
基础教程推荐
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
