Install Python on Alpine Linux - Docker


Install Python on Alpine Linux - Docker

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


Have Questions? Post them here!
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.