Docker-alpine: apk not working in v3.7

Created on 30 May 2018  路  5Comments  路  Source: gliderlabs/docker-alpine

Hi,

I did the following

$ docker run -it alpine:3.7
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
2 errors; 11 distinct packages available

Also,

/ # apk add curl
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  curl (missing):
    required by: world[curl]
/ # cat /etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/v3.7/main
http://dl-cdn.alpinelinux.org/alpine/v3.7/community

Outside of Docker container, wget of http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz gave me the file successfully.

Most helpful comment

I found myself having the same issue

docker run -it --rm alpine:3.7
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
2 errors; 11 distinct packages available
/ #

I did try to make a wget request:

/ # wget http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
wget: bad address 'dl-cdn.alpinelinux.org'

And an nslookup:

/ # nslookup dl-cdn.alpinelinux.org
nslookup: can't resolve '(null)': Name does not resolve

^C
/ #

And another one

/ # nslookup dl-cdn.alpinelinux.org 8.8.8.8
Server:    8.8.8.8
Address 1: 8.8.8.8

nslookup: can't resolve 'dl-cdn.alpinelinux.org': Try again
/ #

So it looks like a DNS issue, but in the host it works:

nslookup dl-cdn.alpinelinux.org
Server:         10.0.1.1
Address:        10.0.1.1#53

Non-authoritative answer:
dl-cdn.alpinelinux.org  canonical name = global.prod.fastly.net.
Name:   global.prod.fastly.net
Address: 151.101.112.249

from the alpine container the ping works:

/ # ping 151.101.112.249 -w 1
PING 151.101.112.249 (151.101.112.249): 56 data bytes
64 bytes from 151.101.112.249: seq=0 ttl=53 time=38.416 ms

--- 151.101.112.249 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 38.416/38.416/38.416 ms

hacky fix

Since it is a DNS error I added in the hosts file the IP of the nslookup of the host:
echo "151.101.112.249 dl-cdn.alpinelinux.org" >> /etc/hosts
Proof:

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
2 errors; 11 distinct packages available
/ # echo  "151.101.112.249 dl-cdn.alpinelinux.org" >> /etc/hosts
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
v3.7.0-193-g2271c9b08f [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-184-ge62f3c3781 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 8879 distinct packages available
/ #

It was a DNS issue

I host my DNS server in a docker container.
The problem was that the DNS server was the docker's LAN IP address.
Being so, the server replied with its private address (the bridge one).
Basically, the request was sent to the IP 10.0.0.1 and the answer was received wit the IP172.17.0.1 as a source IP, so the query answer was rejected.
I did try to create a temporary container with the --dns flag to the correct IP and it worked flawlessly.
My definitive fix was to edit the /etc/docker/daemon.json file, adding this line:

{
    "dns": ["172.17.0.1"]
}

All 5 comments

I can't reproduce:

$ docker run -it --rm alpine:3.7
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-189-g6afe8a2fd5 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-184-ge62f3c3781 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 9054 distinct packages available
/ # apk add curl
(1/4) Installing ca-certificates (20171114-r0)
(2/4) Installing libssh2 (1.8.0-r2)
(3/4) Installing libcurl (7.60.0-r1)
(4/4) Installing curl (7.60.0-r1)
Executing busybox-1.27.2-r7.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 6 MiB in 15 packages

I found myself having the same issue

docker run -it --rm alpine:3.7
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
2 errors; 11 distinct packages available
/ #

I did try to make a wget request:

/ # wget http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
wget: bad address 'dl-cdn.alpinelinux.org'

And an nslookup:

/ # nslookup dl-cdn.alpinelinux.org
nslookup: can't resolve '(null)': Name does not resolve

^C
/ #

And another one

/ # nslookup dl-cdn.alpinelinux.org 8.8.8.8
Server:    8.8.8.8
Address 1: 8.8.8.8

nslookup: can't resolve 'dl-cdn.alpinelinux.org': Try again
/ #

So it looks like a DNS issue, but in the host it works:

nslookup dl-cdn.alpinelinux.org
Server:         10.0.1.1
Address:        10.0.1.1#53

Non-authoritative answer:
dl-cdn.alpinelinux.org  canonical name = global.prod.fastly.net.
Name:   global.prod.fastly.net
Address: 151.101.112.249

from the alpine container the ping works:

/ # ping 151.101.112.249 -w 1
PING 151.101.112.249 (151.101.112.249): 56 data bytes
64 bytes from 151.101.112.249: seq=0 ttl=53 time=38.416 ms

--- 151.101.112.249 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 38.416/38.416/38.416 ms

hacky fix

Since it is a DNS error I added in the hosts file the IP of the nslookup of the host:
echo "151.101.112.249 dl-cdn.alpinelinux.org" >> /etc/hosts
Proof:

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
2 errors; 11 distinct packages available
/ # echo  "151.101.112.249 dl-cdn.alpinelinux.org" >> /etc/hosts
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz
v3.7.0-193-g2271c9b08f [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-184-ge62f3c3781 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 8879 distinct packages available
/ #

It was a DNS issue

I host my DNS server in a docker container.
The problem was that the DNS server was the docker's LAN IP address.
Being so, the server replied with its private address (the bridge one).
Basically, the request was sent to the IP 10.0.0.1 and the answer was received wit the IP172.17.0.1 as a source IP, so the query answer was rejected.
I did try to create a temporary container with the --dns flag to the correct IP and it worked flawlessly.
My definitive fix was to edit the /etc/docker/daemon.json file, adding this line:

{
    "dns": ["172.17.0.1"]
}

I think that if @shaunthomas999 doesn't have any more issue, this can be closed

@Pandry - With the fix you provided, issue is resolved. Thanks 馃憤

global.prod.fastly.net had to be allowed by our Network Security Analyst

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dinogun picture dinogun  路  3Comments

mterzo picture mterzo  路  4Comments

rmNyro picture rmNyro  路  4Comments

frebib picture frebib  路  4Comments

kooksee picture kooksee  路  4Comments