【发布时间】:2021-05-17 01:13:01
【问题描述】:
我正在尝试更新在 docker 容器中运行的 python 版本,但即使我尝试使用 apt-get update 或 apt update 更新软件包,然后运行 apt-get install python3.8 或 apt install python3.8 我得到以下信息错误:
apt install python3.8
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.8
E: Couldn't find any package by glob 'python3.8'
E: Couldn't find any package by regex 'python3.8'
我已经尝试过这个链接的答案:How to Install python3.8 on debian 10?
更多信息:
我的 docker-compose.yml
version: "3.3"
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USER}
POSTGRES_DB: ${DB_DATABASE}
volumes:
- ./pgdata:/var/lib/postgres/data
ports:
- "${DB_PORT}:${DB_PORT}"
web:
image: node:12
restart: always
depends_on:
- db
ports:
- 3000:3000
volumes:
- ./:/usr/app
working_dir: /usr/app
command: bash -c "apt-get update && apt-get install -y python3 wget && wget https://bootstrap.pypa.io/pip/3.5/get-pip.py && python3 get-pip.py && pip install opencv-contrib-python==4.1.2.30 && pip3 install numpy && pip3 install imutils && pip3 install pickle-mixin && pip3 install argparse && pip3 install requests && yarn && rm -rf get-pip.py && yarn start"
environment:
IMAGE_DIR_NAME: ${my_path}
PYTHON_PATH: ${my_path}
SCRYFALL_SCRIPT: ${my_path}
DB_HOST: db
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"
我该如何解决这个问题?
【问题讨论】:
-
根据Docker Hub,
node:12基于 Stretch(即 Debian 9)。从某些 PPA 等安装 Python 3.8 可能会更好。 -
您最好将其重构为单独的 Dockerfile,这样每次启动容器时都不必重复冗长的
command:。尚不清楚为什么您需要在基于node的容器中使用特定的 Python 版本;你可以使用一个单独的容器,内置在 DockerfileFROM python:3.8中,运行 Python 组件吗?
标签: python node.js python-3.x docker docker-compose