I need to install python on running container, based empty alpine image. That is my run command:
docker run -it alpine:3.14 sh
And then I get a shell, like this:
/ #
Then, i want to install python
/ # apt-get update -y
/ # apt-get install -y python
But I get this error:
sh: apt-get: not found
I try to install bash by those commands but it doesn't work
/ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
v3.14.2-40-gf566f645a9 [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.2-42-gf168ad374f [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
OK: 14938 distinct packages available
/ # apk upgrade
OK: 6 MiB in 14 packages
/ # apk add bash
(1/4) Installing ncurses-terminfo-base (6.2_p20210612-r0)
(2/4) Installing ncurses-libs (6.2_p20210612-r0)
(3/4) Installing readline (8.1.0-r0)
(4/4) Installing bash (5.1.4-r0)
Executing bash-5.1.4-r0.post-install
Executing busybox-1.33.1-r3.trigger
OK: 8 MiB in 18 packages
/ # bash
bash-5.1# apt-get update -y
bash: apt-get: command not found
My question is: is it possible to install python on shell?
P.S: I must do it in the container and must use in empty alpine image
Thanks!!
CodePudding user response:
apt-get
is Debian/Ubuntu's package manager. On Alpine you need to stick with apk
, the Alpine package manager.
If you run across Docker guides that use apt-get
you can't run the commands directly. You need to look up the equivalent package names and use apk
.
# apk update
# apk add python3