Alpine linux installing Python3 as a package dependency even though its a Balena Python container

When I run the Balena Python container:

docker run -it balenalib/orange-pi-zero-alpine-python:3.8.5 sh

and search for Python I see the packages:

find -iname python3*
./usr/local/lib/python3.8
./usr/local/lib/pkgconfig/python3-embed.pc
./usr/local/lib/pkgconfig/python3.pc
./usr/local/bin/python3.8-config
./usr/local/bin/python3
./usr/local/bin/python3-config
./usr/local/bin/python3.8
./usr/local/share/man/man1/python3.1
./usr/local/share/man/man1/python3.8.1
./usr/local/include/python3.8

Yet when I then install a package into the container, which has a Python dependency, Python gets installed again:

apk add supervisor
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/armv7/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/armv7/APKINDEX.tar.gz
(1/10) Installing gdbm (1.13-r1)
(2/10) Installing python3 (3.8.5-r0)
(3/10) Installing py3-meld3 (2.0.1-r0)
(4/10) Installing py3-ordered-set (4.0.1-r0)
(5/10) Installing py3-appdirs (1.4.4-r1)
(6/10) Installing py3-parsing (2.4.7-r0)
(7/10) Installing py3-six (1.15.0-r0)
(8/10) Installing py3-packaging (20.4-r0)
(9/10) Installing py3-setuptools (47.0.0-r0)
(10/10) Installing supervisor (4.2.0-r0)
Executing busybox-1.31.1-r16.trigger
OK: 102 MiB in 83 packages

When I then do the search again, I see it installed in two different places:

find -iname python3*
./usr/lib/python3.8
./usr/bin/python3
./usr/bin/python3.8
./usr/local/lib/python3.8
./usr/local/lib/pkgconfig/python3-embed.pc
./usr/local/lib/pkgconfig/python3.pc
./usr/local/bin/python3.8-config
./usr/local/bin/python3
./usr/local/bin/python3-config
./usr/local/bin/python3.8
./usr/local/share/man/man1/python3.1
./usr/local/share/man/man1/python3.8.1
./usr/local/include/python3.8
./usr/include/python3.8

This is adding extra weight to my containers. Is there a way to allow Alpine to use the pre-installed Python package provided by Balena?

I have also noted that Balena Python container is significantly larger than the Balena Alpine container with Python installed via apk add python3 and apk add py3-pip:

<none>                                   <none>    4fc3d46b3aad   5 seconds ago    110MB
balenalib/orange-pi-zero-alpine-python   3.8.6     9d77539bbf53   5 days ago       161MB

Is there documentation that shows what is in the container that makes it 60% bigger?

Installing the package with pip install supervisor solved the issue of using APK.

Hi,

You can take a look at the balenalib image on hub.docker.com to get some insights.

John