14

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!

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
EngineerBetter_DJ
  • 241
  • 1
  • 2
  • 5

3 Answers3

6

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

Philip Kirkbride
  • 9,816
  • 25
  • 95
  • 167
Francesco Colista
  • 1,347
  • 10
  • 21
5

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.

-5

Run:

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

and then

apk update && apk add wget curl
AdminBee
  • 21,637
  • 21
  • 47
  • 71