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!


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".


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:


... 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.

  • wget as it is used is not GNU wget, rather is built-in with busybox. So you don't need to install curl. – Francesco Colista Apr 4 '19 at 14:27


apk --update add git less openssh &&  rm -rf /var/lib/apt/lists/* && rm /var/cache/apk/*

and then

apk update && apk add wget curl
New contributor
Hema Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.