首页 > 解决方案 > 无法使用 python docker image 使用已安装的包

问题描述

尝试在docker容器中执行cowsay命令,但出现bash: cowsay: not found。这种情况发生在 sl 包的情况下。我使用 python:3.9 图像。我的 Dockerfile -

FROM python:3.9

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y cowsay && apt-get install -y sl
RUN pip install --upgrade pip


COPY ./requirements.txt .
RUN pip install -r requirements.txt

COPY . .

和 docker run 命令 -

docker run -it --entrypoint bash

标签: pythondocker

解决方案


推荐阅读