Error Docker saying bad file descriptor

+6 votes

 ERROR: Bad file descriptor during apk update in Docker container

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: Bad file descriptor
WARNING: Ignoring APKINDEX.70c88391.tar.gz: Bad file descriptor
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: Bad file descriptor
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: Bad file descriptor
2 errors; 33 distinct packages available
Mar 27, 2018 in Docker by Atul
• 10,240 points

recategorized Oct 16, 2018 by Kalgi 7,946 views

4 answers to this question.

+2 votes
Best answer

The solution was easy enough. Add these 2 lines to your RUN command:

rm -rf /var/cache/apk && \
mkdir /var/cache/apk && \

In Dockerfile ...

RUN apk add --update --no-cache bash \
    git \
    make \
    clang \
    g++ \
    go && \
    mkdir -p $REPO && \
    mkdir -p $GODIR/src && \
    rm -rf /usr/share/man && \
    rm -rf /var/cache/apk && \
    mkdir /var/cache/apk && \
    apk del git clang
answered Mar 27, 2018 by DragonLord999
• 8,450 points

selected Oct 11, 2018 by Priyaj
+2 votes

Try modifying your Docker file something like this:

RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.5/main > /etc/apk/repositories; \
    echo http://mirror.yandex.ru/mirrors/alpine/v3.5/community >> /etc/apk/repositories

RUN apk update \
 && apk add --no-cache \
...
answered Oct 11, 2018 by Hannah
• 18,520 points
0 votes

It's a DNS lookup error. Just add google DNS servers (8.8.8.8, 8.8.4.4) to your Docker host's deamon config file.

answered Oct 16, 2018 by Kalgi
• 52,350 points
0 votes

Add the following to your Dockerfile:

RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.5/main > /etc/apk/repositories;
echo http://mirror.yandex.ru/mirrors/alpine/v3.5/community >> /etc/apk/repositories
answered Oct 16, 2018 by lina
• 8,220 points

edited Oct 16, 2018 by Kalgi
I honestly don't think this is a very good idea.
Why is that so kalgi?
It's always risky to add packages from non-official sources, you never know what error or change in the configuration it might result into.

Related Questions In Docker

0 votes
1 answer

Error saying "build" requires 1 argument. See 'docker build --help'

Try adding a period at the end ...READ MORE

answered Jul 18, 2018 in Docker by Nilesh
• 7,060 points
4,894 views
0 votes
1 answer
0 votes
1 answer

Error saying "E: This command can only be used by root." while installing docker

Try executing the following command: sudo su and ...READ MORE

answered Aug 6, 2019 in Docker by Ahmad
6,941 views
0 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,739 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP