【问题标题】:How install PIP & PYMSSQL in docker如何在 docker 中安装 PIP 和 PYMSSQL
【发布时间】:2021-09-15 10:06:30
【问题描述】:

我有一个要在 Azure Kubernetes 中执行的 Python 程序。

下面是我的 docker 文件 - 我已经安装了 Python

#Ubuntu Base image with openjdk8 with TomEE

FROM demo.azurecr.io/ubuntu/tomee/openjdk8:8.0.x

RUN apt-get update && apt-get install -y telnet && apt-get install -y ksh && apt-get install -y python2.7.x && apt-get -y clean && rm -rf /var/lib/apt/lists/*

但是我不知道如何安装 PIP 和相关的依赖库(例如:pymssql)?

【问题讨论】:

  • 如果你开始你的镜像FROM python:3.9Docker Hub python image包含pip,然后你可以RUN pip install -r requirements.txt包含你的Python库依赖。
  • 很遗憾我必须使用python 2.7.5,请建议。
  • Python 2.7 已有十多年的历史,一年半前 Python 团队制作了 the last Python 2.x release ever。我强烈建议您将应用程序更新为受支持的语言版本。

标签: python docker azure-aks


【解决方案1】:

最好的选择是在 docker 镜像上安装 miniconda。当我需要在没有 python 或 pip 的 docker 图像上使用 python 时,我总是使用它。

这是在我的简单 docker 镜像中安装 minicinda 的部分

FROM debian
RUN apt-get update && apt-get install -y curl wget
RUN 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

【讨论】:

  • A 已通过 miniconda 安装添加了 Dockerfile 的一部分
  • 谢谢,生产使用需要许可证吗?是否支持 Python 2.7.5?
  • 我只将它用于本地解决方案,我认为您可以使用商业(但请检查这些——我不擅长许可证主题)。是的,您可以使用 python 2.7 配置环境。
猜你喜欢
  • 2016-12-09
  • 2016-10-12
  • 2016-08-05
  • 2013-06-26
  • 1970-01-01
  • 2021-10-03
  • 2017-12-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多