After running:
docker network rm $NETNAME
docker network create --driver bridge $NETNAME --subnet "${SUBNET}0/24"
docker run --name $NODENAME -it --net $NETNAME --ip 192.168.0.2 --volume --detach $IMGNAME
inside the container, as root, I run apk udpdate
:
# 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: 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
... and hit the Bad file descriptor
error.
There a number of other folks that have encountered the same error:
CDN seems to be down and cannot get mirrors working #280
Repository problem? #279
Suggestions on how to resolve this range from:
"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."
... to ...
"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
(Which you should NOT do. Never add packages from non-official sources.)
Solution
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
Adding commands to delete and recreate the /var/cache/apk
directory feels like a hack.
My hack works, but what is the root cause of this error and who should fix it?
--no-cache
option allows to not cache the index locally.
That is helpful in keeping the container small.
Also, it is equivalent to apk update
at the top and rm -rf /var/cache/apk/
in the end.
So you can try to use it this way:
RUN apk add --update --no-cache bash \
git \
make \
clang \
g++ \
go && \
mkdir -p $REPO && \
mkdir -p $GODIR/src && \
rm -rf /usr/share/man && \
apk del git clang
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With