0

I'm trying to update my python version that runs inside a docker container, but even when i try to update the packages with apt-get update or apt update and then running apt-get install python3.8 or apt install python3.8 i got the following error:

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'

I have already tried the answer on this link: How to Install python3.8 on debian 10?

More informations:

My 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"

How can i solve this problem?

  • According to [Docker Hub](https://hub.docker.com/_/node), `node:12` is based on Stretch (i.e. Debian 9). You may have better luck installing Python 3.8 from some PPA or such. – iBug May 17 '21 at 01:18
  • You might be better off refactoring this into a separate Dockerfile, so that long-winded `command:` doesn't have to be repeated every time you start the container. It's not totally clear why you need a specific Python version in a `node`-based container; can you use a separate container, built in a Dockerfile `FROM python:3.8`, that runs the Python component? – David Maze May 17 '21 at 04:34

1 Answers1

1

I particularly suggest you to compile an image using multistage example alpine that will get smaller or even use a distroless with python3.8 and node12 is smaller and more secure container! but if you want a simpler solution have these source code available that works perfectly for your problem

here python and node image souce code https://github.com/nikolaik/docker-python-nodejs

from docker hub image

nikolaik/python-nodejs:python3.8-nodejs12-alpine

and here distroless images

https://github.com/GoogleContainerTools/distroless

Emerson Pedroso
  • 181
  • 3
  • 13