提问人:Paanik 提问时间:8/4/2023 最后编辑:OneCricketeerPaanik 更新时间:8/4/2023 访问量:85
如何为 apt-get install python3.8 不再支持的旧 Ubuntu 版本 (16.04) 构建 Dockerfile?
How to build Dockerfile for an old Ubuntu version (16.04) no longer supported by apt-get install python3.8?
问:
我有以下问题:我必须为 Ubuntu 16.04 和 Python 3.8 构建一个 docker 映像(需要将 MSSQL 16 用于 Django,我必须使用 MSSQL 16),但此版本不存在 Docker 的官方 Python 映像。
我正在 VM 上使用 Docker Desktop 在 Windows 上工作。我来到了以下 Dockerfile(我不得不避免或 pip,因为不再支持此 ubuntu 版本):apt-get install python3.8
FROM ubuntu:16.04
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /app
# Update the package list and install necessary packages
RUN apt-get update && \
apt-get install -y wget build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev \
libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev uuid-dev \
apt-transport-https gnupg2 curl
# Download Python 3.8.15 source
RUN wget https://www.python.org/ftp/python/3.8.15/Python-3.8.15.tgz && \
tar xvf Python-3.8.15.tgz && \
cd Python-3.8.15 && \
./configure --enable-optimizations && \
make -j 3 && \
make install && \
cd .. && \
rm -rf Python-3.8.15 && \
rm Python-3.8.15.tgz
# Add Python 3.8 binary path to the PATH environment variable
ENV PATH="/usr/local/bin:${PATH}"
# Install pip for Python 3.8
RUN wget https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
rm get-pip.py
# Download poppler and Microsoft ODBC driver (instructions at https://github.com/MicrosoftDocs/sql-docs/blob/live/docs/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server.md#13)
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql=13.0.1.0-1 mssql-tools=14.0.2.0-1 unixodbc-dev-utf16 libodbc1-utf16 \
poppler-utils
# populate "ocbcinst.ini"
RUN echo "[ODBC Driver 13 for SQL Server]\n\
Description = Microsoft ODBC Driver 13 for SQL Server\n\
Driver = /opt/microsoft/msodbcsql13/lib64/libmsodbcsql-17.2.so.0.1\n\
UsageCount=1" >> /etc/odbcinst.ini
# requirements for dev
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["echo", "$PATH"]
# CMD ["python3", "--version"]
#"manage.py", "runserver", "0.0.0.0:8000"
现在,它似乎运行了,但它告诉我,当我在CMD命令中没有使用python时,我遇到了Python错误?
[+] Running 2/2
✔ Network autocheck_default Created 2.1s
✔ Container autocheck_web Created 6.9s
Attaching to autocheck_web
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create
failed: unable to start container process: exec: "python": executable file not found in $PATH: unknown
有人可以帮我知道这里出了什么问题吗?我试图修剪 docker 和 $env:COMPOSE_HTTP_TIMEOUT=480(试图在这里获得想法),但它没有用。 如果有更快的方法来构建 docker 镜像,我很乐意这样做,因为这需要很多时间!
多谢!
答: 暂无答案
评论
ENV PATH
FROM python:3.8