【发布时间】:2020-09-18 20:30:06
【问题描述】:
我正在处理我的一个 Flask 项目,当我第二天启动我的电脑时,它不再运行了。我尝试重新安装 Docker,甚至重新安装我的操作系统(Ubuntu),即使使用基本示例 Hello World Python 项目,这个错误仍然出现。以下是尝试构建一个简单的 Hello World 项目的输出:
# docker build -t hello-world .
Sending build context to Docker daemon 4.608kB
Step 1/6 : FROM python:3.8
---> 659f826fabf4
Step 2/6 : WORKDIR /usr/src/app
---> Using cache
---> 5e381e0b49f2
Step 3/6 : COPY requirements.txt ./
---> Using cache
---> 4d46722cff64
Step 4/6 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 305e14db0fa2
/usr/local/bin/python: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 127
Dockerfile:
FROM python:3.8
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./run.py" ]
运行.py
print("Hello World")
而且 requirements.txt 是空的。它昨天还在工作,我一直在努力弄清楚为什么它现在不工作。
【问题讨论】:
-
请同时分享 requirements.txt
-
这个例子是空的
-
你是如何安装 Python 3.8 的,你是如何安装 Docker 的?
-
我使用 snap 在 Ubuntu 上安装 Docker,据我了解,Docker 通过 docker build 安装 Python 3.8(在 Dockerfile 中指定)。
-
我还看到过其他一些关于 snap-installed Docker 无法正常运行的投诉,但更多的是“权限被拒绝”类型错误(eg、Can't run any container with an entrypoint script、Permission denied as root in docker containers )。使用 APT 而不是 snap 重新安装 Docker 会有所改善吗?
标签: python linux docker ubuntu docker-compose