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 26, 2018 in Docker by Atul
• 10,200 points

recategorized Oct 16, 2018 by Kalgi 594 views

4 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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 26, 2018 by DragonLord999
• 8,360 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
• 14,080 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
• 35,750 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,100 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
• 6,900 points
247 views
0 votes
1 answer
+2 votes
6 answers

If conditional in docker file

You can use the test command RUN test ...READ MORE

answered Dec 10, 2018 in Docker by Shushant
7,492 views
0 votes
1 answer

Preferred method for Docker File Versioning

Use labels to add versioning information to ...READ MORE

answered Jun 11, 2018 in Docker by ajs3033
• 7,000 points
61 views
0 votes
1 answer
0 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
• 56,120 points
56 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.