Did the package you want to install move to a different registry?
Sometimes the packages that are being installed are moved from different registry branches. The default Docker Alpine image only has certain registries set. Adding additional registries expands your installation options (YMMV); I can't speak to the stability, security, and or risks associated with different registry branches. This thread helped me.
Failed Attempt & Error Message:
❯ docker run -it alpine sh
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.0-175-g8b3334c57c [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.0-178-gb27c83e867 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12749 distinct packages available
/ # apk add cowsay
ERROR: unsatisfiable constraints:
cowsay (missing):
required by: world[cowsay]
/ #
- Our first clue from the output
ERROR: unsatisfiable constraints:
cowsay (missing):
required by: world[cowsay]
- Second Clue from the output
earlier in the log
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
Solutioning
- Search on DuckDuckGo for
package <package name>
Which type of memory am I using?
- The answer is found in clue # 2. x86_64
On the page for the packages select the proper link. so in my case:
Reading the information on that page I see that under Download the binary for this package is in presently part of
http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/cowsay-3.04-r0.apk
Comparing this to clue #2, I see that the alpine container is not referencing the registry with the binary I want to install.
Success & TL;DR;
Adding a package previously not found to alpine by adding additional registry to docker alpine container.
I'll add the registry that I need to find the package I want to install (step #3). In the code block below see that the third registry matches the initial part of the URL from the research done in part #3. I don't want to replace the existing registries (clue #2) so I set those again. I don't know if this is necessary or not but I did it anyway.
$ docker run -it alpine sh
/# apk update && apk add cowsay \
--update-cache \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/community \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/main \
--repository https://dl-3.alpinelinux.org/alpine/edge/testing
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.0-175-g8b3334c57c [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.0-178-gb27c83e867 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12749 distinct packages available
fetch https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch https://alpine.global.ssl.fastly.net/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://alpine.global.ssl.fastly.net/alpine/edge/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libbz2 (1.0.8-r1)
(2/3) Installing perl (5.30.3-r2)
(3/3) Installing cowsay (3.04-r0)
Executing busybox-1.31.1-r16.trigger
OK: 43 MiB in 17 packages
/ #
Dockerfile example
FROM alpine
RUN apk update && apk add cowsay \
--update-cache \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/community \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/main \
--repository https://dl-3.alpinelinux.org/alpine/edge/testing
CMD ["cowsay", "hi stackoverflow"]
After building this file:
❯ docker run cowsay [13:13:45]
__________________
< hi stackoverflow >
------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||