如何在ubuntu 18.04容器中获取python3.10

问题描述 投票:0回答:2

我正在寻找一些编写 docker 文件的帮助,该文件最终创建一个带有 Python 3.10 可执行文件的 Ubuntu 18.04 容器。

有什么方法可以让 Ubuntu 18.04 获得 Python3.10 吗?要求是使用来自 docker hub 的瘦身或非瘦身版本的 Python3.10 [Bulls eye][1] 图像

docker dockerfile ubuntu-18.04 python-3.10
2个回答
2
投票

您可以使用Ubuntu 18 docker镜像,然后在其中安装python 3.10。

FROM ubuntu:18.04
RUN apt-get -y update && apt -get install software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa && apt install python3.10

-4
投票

我可以通过包含 python3.10 在 ubuntu 18.04 上构建图像

Step-1: 编写 docker 文件 来自 python:3.10-bullseye 运行 mkdir WORK_REPO 运行cd WORK_REPO 工作目录/WORK_REPO 添加 hi.py 。 CMD [“python”,“-u”,“hi.py”]

第 2 步: 构建镜像 docker build -t image_name .

第3步:运行docker镜像 docker run image_name

Step-4: 连接容器并检查Python版本

我希望这对刚开始编写 dockerfile 的人有所帮助。

非常感谢, 苏雷什。

© www.soinside.com 2019 - 2024. All rights reserved.