In order to install Python on Alpine Linux the smallest and most security-oriented Linux distribution mostly used with Docker, you will need to make use of the apk - the alpine package manager.
Example:% docker run -it --name python-with-alpine alpine
# apk add python3
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/aarch64/APKINDEX.tar.gz
(1/13) Installing libbz2 (1.0.8-r1)
(2/13) Installing expat (2.4.8-r0)
(3/13) Installing libffi (3.4.2-r1)
(4/13) Installing gdbm (1.23-r0)
(5/13) Installing xz-libs (5.2.5-r1)
(6/13) Installing libgcc (11.2.1_git20220219-r2)
(7/13) Installing libstdc++ (11.2.1_git20220219-r2)
(8/13) Installing mpdecimal (2.5.1-r1)
(9/13) Installing ncurses-terminfo-base (6.3_p20220521-r0)
(10/13) Installing ncurses-libs (6.3_p20220521-r0)
(11/13) Installing readline (8.1.2-r0)
(12/13) Installing sqlite-libs (3.38.5-r0)
(13/13) Installing python3 (3.10.5-r0)
Executing busybox-1.35.0-r17.trigger
OK: 57 MiB in 27 packages
# python3 --version
Python 3.10.5
You can also get it installed using the RUN instruction in a Dockerfile,
Python3 on Alpine Linux using Dockerfile
FROM alpine:latest
RUN apk add python3
CMD python3 --version
% docker build -t alpine-python .
% docker run -it alpine-python
Python 3.10.5
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Docker,
- Install Docker on Mac using brew cask
- How to know the Docker Sandbox ID of a Container Network?
- How to Rename Docker Image with none TAG and REPOSITORY?
- How to know list of images available on your device
- Docker Alpine Linux and Apache2 Example
- Install Bash on Alpine Linux - Docker
- Docker Run Command Examples - Part 1
- Install the minimal Linux on Docker (only 5 mb Alpine Linux)
- [fix] docker: Error response from daemon: dial unix docker.raw.sock: connect: no such file or directory.
- Install RabbitMQ on Docker
- How to know docker Engine details
- [Fix] Docker Error response from daemon: manifest for :latest not found: manifest unknown
- How to stop and start a docker container
- How to create volume in Docker using Command
- How to know the Docker Engine Version
- [docker] Error response from daemon: No such container
- Install Docker for Mac using Home-brew Cask
- Docker - Incompatible CPU detected - M1/M2 Mac (macOS Sonoma)
- [fix] Docker Desktop App not starting on Mac (macOS)
- Unable to find image docker latest locally
- How to Stop/Cancel/kill docker image pull
- List of what's new in Docker 4.23
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac
- Docker - Running in Resource Saver mode
More Posts:
- Docker Init Command to Create Starter Files for Your Project - Docker
- How to uninstall pip Python packages - Python
- How to display File CR LF Newline Characters in Sublime Text - Sublime-Text
- Install Gradle VS Code for Java Projects - Gradle
- Fix: Deprecated Gradle features were used in this build, making it incompatible with Gradle - Gradle
- Create a Database Table using JDBC PreparedStatement - Java
- How to Create Awesome Quizzes using Windows 365 Forms - Windows
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac - Docker