Apk not working on alpine linux image

Trying to install erlang-observer using apk add erlang-observer.

Running docker on on Ubuntu 22.04.4 host.

Keep getting the following error:

(1/5) Installing erlang-kernel (18.3.2-r0)
ERROR: erlang-kernel-18.3.2-r0: temporary error (try again later)
(2/5) Installing erlang-stdlib (18.3.2-r0)
ERROR: erlang-stdlib-18.3.2-r0: temporary error (try again later)
(3/5) Installing erlang-compiler (18.3.2-r0)
ERROR: erlang-compiler-18.3.2-r0: temporary error (try again later)
(4/5) Installing erlang (18.3.2-r0)
ERROR: erlang-18.3.2-r0: temporary error (try again later)
(5/5) Installing erlang-observer (18.3.2-r0)
ERROR: erlang-observer-18.3.2-r0: temporary error (try again later)
5 errors; 38 MiB in 28 packages

Using the following docker-compose file

version: "0.0"

services:
  alpine-elixir:
    image: bitwalker/alpine-elixir:1.3.4
    volumes:
      - ./:/app
    working_dir: /app

apk just seems to not be working. Is it related to dns?

Have you waited a bit and tried again?

Maybe just give it a try. Add some DNS servers to your Compose file.

version: "0.0"

services:
  alpine-elixir:
    image: bitwalker/alpine-elixir:1.3.4
    volumes:
      - ./:/app
    working_dir: /app
    dns:
      - 1.1.1.1
      - 4.4.4.4
      - 8.8.8.8

That image is really old based on a really old alpine (v3.4) and the repository domain changed since then. I wouldn’t use such an old image. The latest is 1.15.0, but if you still want to use it for legacy applications, you need to change /etc/apk/repositories

sed -i 's/alpine\.gliderlabs\.com/dl-cdn.alpinelinux.org/g' /etc/apk/repositories
sed -i '/^@edge/d' /etc/apk/repositories

then don’t forget to update the cache

apk update

After that, you should be able to install the package…

To make it persistent, you can add these commands to a Dockerfile and create your own image with bitwalker/alpine-elixir:1.3.4 as base image, or just simply mount this file:

http://dl-cdn.alpinelinux.org/alpine/v3.4/main
http://dl-cdn.alpinelinux.org/alpine/v3.4/community

to /etc/apk/repositories in the volumes section of the compose file

That fixed it. Thank you so much!

Thanks for your help! I thought it could have something to do with the dns servers but It was because I was using an outdated repository. Was resolved by: