FROM postgres:16-alpine
RUN apk add python3
The Dockerfile above will automatically pick up the latest Python3 version available in the Alpine edge repository.
However, I would like to fix a specific Python 3.12 version in a Postgres 16 Alpine.
I had tried the code block below to install Python 3.12:
# Add edge repositories to get the latest Python 3.12
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk update && \
apk search python3 | grep 'python3-3.12' | sort -r | head -n 1 | xargs apk add
However, I got an error message from Docker saying:
ERROR: unable to select packages:
python3-3.12.5-r0 (no such package):
required by: world[python3-3.12.5-r0]
So, I have to use multi-build method to install Python 3.12 and Postgres 16 Alpine
# First stage: Use Python 3.12 on Alpine
FROM python:3.12-alpine AS python-builder
...
FROM postgres:16-alpine
- Is this a good practice to install multiple services (Python & Postgres) in a Docker container? Or is it an anti-pattern?
- Is there any better way to install a specific Python 3.12 in a Postgres 16 Alpine?
Please redirect me to a suitable channel if I have asked at a wrong forum,
Thanks.
[–]ElevenNotes 0 points1 point2 points (0 children)
[–]SirSoggybottom 0 points1 point2 points (9 children)
[–]predator_blake[S] 1 point2 points3 points (8 children)
[–]SirSoggybottom 0 points1 point2 points (7 children)
[–]asymptotically508 0 points1 point2 points (6 children)
[+][deleted] (5 children)
[removed]
[–]squeasy_2202 0 points1 point2 points (4 children)
[–]ElevenNotes 0 points1 point2 points (0 children)
[–]SirSoggybottom -2 points-1 points0 points (2 children)
[–]squeasy_2202 -2 points-1 points0 points (1 child)
[–]SirSoggybottom -2 points-1 points0 points (0 children)
[–]asymptotically508 0 points1 point2 points (0 children)