Install apk tool on Alpine Linux
Solution 1
Probably you mean v3.5.0.
The easier way is (if your architecture is x86_64):
wget http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/apk-tools-static-2.6.8-r1.apk
And then unpack the downloaded file:
tar -zxvf apk-tools-static-2.6.8-r1.apk
You'll find in the unpacked apk the apk.static file, that you can use to install apk-tools.
More info here: https://wiki.alpinelinux.org/wiki/Upgrading_Alpine
Of course, if your architecture is x86, the url is:
wget http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86/apk-tools-static-2.6.8-r1.apk
Anyway, the package you need is "apk-tools".
Solution 2
One addition to Francesco's answer (since I don't have the reputation to comment yet):
You may need to use the curl
command with the -o
flag instead of wget, depending on how your container is configured. (If you get a wget: command not found
message, that's probably a good fallback.)
===
Edit: Also, it looks from the "packages" page like they may have removed this minor version in favor of 2.6.9:
https://pkgs.alpinelinux.org/packages?name=apk-tools-static&branch=&repo=&arch=&maintainer=
... so the command set I ended up using was more like:
curl -o apk-tools-static-2.6.8-r1.apk http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/apk-tools-static-2.6.9-r0.apk
tar -zxvf apk-tools-static-2.6.8-r1.apk
cd sbin
sudo ./apk.static -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main -U --allow-untrusted --initdb add apk-tools-static
sudo apk.static update
sudo ./apk.static -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main -U --allow-untrusted add apk-tools
sudo apk update
... etc.,.
Usual disclaimer: If you can run things without using sudo
, you really should do that. My situation is not your situation. Try everything without sudo
first.
Related videos on Youtube
![EngineerBetter_DJ](https://i.stack.imgur.com/468lE.jpg?s=256&g=1)
EngineerBetter_DJ
I tell computers to do things. Sometimes I even tell them to do the right things. I also help people get better at telling computers to do things. Some of the things I tell computers to do are games, but most are related to distributed services, PaaS, NoSQL, and that sort of thing.
Updated on September 18, 2022Comments
-
EngineerBetter_DJ almost 2 years
I'm fiddling with a Docker image, built from a Virtualbox VM using Packer. The image is Alpine Linux 5.3.0, but
apk
seems to have been removed.How can I reinstall
apk
, or build it from source? Googling seems only to yield results on people installing packages, or Android apps! -
Francesco Colista about 5 yearswget as it is used is not GNU wget, rather is built-in with busybox. So you don't need to install curl.
-
Bat_Programmer over 2 yearsThanks. This worked perfectly for me