gliderlabs / docker-alpine

Alpine Linux Docker image. Win at minimalism!
http://gliderlabs.viewdocs.io/docker-alpine
BSD 2-Clause "Simplified" License
5.71k stars 531 forks source link

IO error when running "apk add" #348

Open tsauvajon opened 7 years ago

tsauvajon commented 7 years ago

Every time I try to install a package via apk add I get IO ERRORs:

apk add --update --no-cache ca-certificates
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz: IO ERROR
ERROR: unsatisfiable constraints:
  ca-certificates (missing):
    required by: world[ca-certificates]

I'm using the alpine:3.6 image on Windows 10 (Docker for Windows - Linux containers)

apk update gives similar results:

apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/main: IO ERROR
WARNING: Ignoring APKINDEX.84815163.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/community: IO ERROR
WARNING: Ignoring APKINDEX.24d64ab1.tar.gz: No such file or directory
2 errors; 11 distinct packages available

I don't seem to have a connection problem:

curl -v http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
*   Trying 151.101.0.249...
* TCP_NODELAY set
* Connected to dl-cdn.alpinelinux.org (151.101.0.249) port 80 (#0)
> GET /alpine/v3.6/community/x86_64/APKINDEX.tar.gz HTTP/1.1
> Host: dl-cdn.alpinelinux.org
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Bst-Request-Id: bNzl6h:H8B:113240
< X-Bst-Info: t=1508702467,h=03d,p=42804_3138:2_11861,u=402895141,c=2339,v=7.9.58904.98
< Server: nginx
< Content-Type: application/octet-stream
< Last-Modified: Tue, 17 Oct 2017 13:38:29 GMT
< ETag: "59e607d5-5b580"
< Accept-Ranges: bytes
< Accept-Ranges: bytes
< Content-Length: 374144
< Date: Sun, 22 Oct 2017 20:01:07 GMT
< Via: 1.1 varnish, 1.1 hosted.websense 03d
< X-Served-By: cache-cdg8731-CDG
< X-Cache: MISS
< X-Cache-Hits: 0
< X-Timer: S1508702467.312061,VS0,VE32
< Connection: keep-alive
<
tsauvajon commented 7 years ago

I'm still having the problem, with the same very simple Dockerfile

FROM alpine:latest

RUN apk --no-cache --update upgrade && apk --no-cache add ca-certificates
andyshinn commented 7 years ago

Have you tried restarting Docker for Windows? This is usually a DNS caching issue with the VM. If you can reproduce it reliably then maybe we need to get into the VM to debug further.

feenst commented 7 years ago

I'm also seeing this error in Docker for Windows (Docker version 17.09.0-ce, build afdb6d4) and Docker on Cent OS 7 (Docker version 17.06.2-ce, build cec0b72).

Same simple Dockerfile that tsauvajon posted above.

Sending build context to Docker daemon  731.1kB
Step 1/2 : FROM alpine:latest
 ---> 053cde6e8953
Step 2/2 : RUN apk --no-cache --update upgrade && apk --no-cache add ca-certificates
 ---> Running in 319b33e585ce
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/main: IO ERROR
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz: IO ERROR
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/community: IO ERROR
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz: IO ERROR
OK: 4 MiB in 11 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz: IO ERROR
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz: IO ERROR
ERROR: unsatisfiable constraints:
  ca-certificates (missing):
    required by: world[ca-certificates]
The command '/bin/sh -c apk --no-cache --update upgrade && apk --no-cache add ca-certificates' returned a non-zero code: 1

Have restarted the VM multiple times and restarted my computer also. I am running Windows 10.

tsauvajon commented 7 years ago

@andyshinn Yes I tried tens of times, while restarting my Windows host and my Docker for Windows several times.

scolson commented 6 years ago

I have this problem too, though I am using Google's container builder. Maybe one or two out of a dozen builds will throw the IO error and force manual intervention to re-run the build step. I have not seen it fail on the second attempt.

This may just be a guess, but considering container builder is a highly jailed environment within some of the best networked datacenters on the planet, I very much doubt it is a "client side" issue.

I'm seeing it on 3.7, fwiw: Step #1: fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz Step #1: fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz Step #1: ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: IO ERROR

slavaaaaaaaaaa commented 6 years ago

I've been running into a similar infuriating issue. Sometimes, I get IO errors installing packages with apk. It seems dependent on how much IO is being performed: an image installing eleven packages only rarely gets these, all I have to do is run build again, while an image installing 86 packages never succeeds.

 $ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM docker:latest
 ---> fd7e073eb60f
Step 2/2 : RUN apk update && apk add     openssh-client     openjdk8-jre     terraform     libc-dev     py-pip     gnupg     make     curl     bash     git     go     jq
 ---> Running in 6f1483a689d8
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
v3.8.1-62-ga10c10dd7d [http://dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.1-61-g338ad9f579 [http://dl-cdn.alpinelinux.org/alpine/v3.8/community]
OK: 9546 distinct packages available
(1/86) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(2/86) Installing ncurses-terminfo (6.1_p20180818-r1)
ERROR: Failed to create usr/share/terminfo/x/xenix: I/O error
ERROR: ncurses-terminfo-6.1_p20180818-r1: IO ERROR
(3/86) Installing ncurses-libs (6.1_p20180818-r1)
(4/86) Installing readline (7.0.003-r0)
(5/86) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
(6/86) Installing nghttp2-libs (1.32.0-r0)
...

...sometimes these errors are instead as such:

ERROR: ncurses-terminfo-6.1_p20180818-r1: BAD archive

Here's a Dockerfile that will reliably produce this for me:

FROM docker:latest

RUN apk update && apk add \
    openssh-client \
    openjdk8-jre \
    terraform \
    libc-dev \
    py-pip \
    gnupg \
    make \
    curl \
    bash \
    git \
    go \
    jq

Quite certain my NVMe drive is fine as it is only a few weeks old and I'm seeing no other IO issues or errors anywhere else.

Here's what I believe to be all the relevant system information::

DISTRIB_DESCRIPTION="Ubuntu 18.10"

Docker version 18.09.0, build 4d60db4

Linux my-pizza 4.18.0-11-generic #12-Ubuntu SMP Tue Oct 23 19:22:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ajardan commented 5 years ago

This looks to me like a Docker BuildKit issue, my build always fails with this IO ERROR with BuildKit enabled, and works when I disable it.

Opened an issue with BuildKit moby/buildkit#746

sciffer commented 5 years ago

Definitely a problem with alpine image, installing gcc/g++ packages on the latest alpine fails with the I/O Error - simple test of adding write permissions to everyone on the /usr folder - make the install work. The maintainers of the image should fix it.

zeinababbasi commented 4 years ago

This was helpful for me.

eslym commented 2 years ago

I am facing same issue with apk add, some package will failed to install and everytime error message will be different, any different packages might fail but mostly gcc or g++ will fail, always failed to create some files

These are errors collected when building the exact same project, no file is modified between these attempts, suddenly success during my 3rd attempt, so it totally became a try your luck situation

(9/26) Installing gcc (11.2.1_git20220219-r2)
ERROR: Failed to create usr/bin/lto-dump: Connection aborted
ERROR: gcc-11.2.1_git20220219-r2: IO ERROR
(9/26) Installing gcc (11.2.1_git20220219-r2)
ERROR: Failed to create usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/liblto_plugin.so: Connection aborted
ERROR: gcc-11.2.1_git20220219-r2: IO ERROR
sanmai-NL commented 1 year ago

@eslym Could it be because of rate limiting?

halvorstein commented 8 months ago

I'm facing the same issue while building an image with BuildKit enabled (MacOS). The process of adding APK packages is failing on random IO errors.

ARG ALPINE_VERSION=3.18
ARG GOLANG_VERSION=1.19.9

FROM --platform=linux/amd64 docker.io/golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION}

RUN set -eux \
    && apk update \
    && apk add --no-cache \
        bash=5.2.15-r5 \
        ca-certificates=20240226-r0 \
        curl=8.5.0-r0 \
        docker-cli=25.0.3-r0 \
        gcc=12.2.1_git20220924-r10 \
        git=2.40.1-r0 \
        helm=3.11.3-r4 \
        librdkafka-dev=2.1.1-r0 \
        make=4.4.1-r1 \
        musl-dev=1.2.4-r2 \
        openssl=3.1.4-r5 \
        py3-pip=23.1.2-r0 \
        python3=3.11.8-r0 \
        python3-dev=3.11.8-r0 \
    && rm -rf /var/cache/apk/*
mosoriorian commented 3 months ago

Hello everyone! Any news on this issue?

t-dubbb commented 1 month ago

Wow, 7 years later and no solution. Time to look for a different distro....

nkarim496 commented 3 weeks ago

and still...