Skip to content

Instantly share code, notes, and snippets.

@xnohat
Forked from yushijinhun/Dockerfile
Created April 19, 2023 09:19
Show Gist options
  • Save xnohat/15deebc396c7179755890442e1aa7ad1 to your computer and use it in GitHub Desktop.
Save xnohat/15deebc396c7179755890442e1aa7ad1 to your computer and use it in GitHub Desktop.
[ubuntu|docker]auto select fastest apt mirror
FROM ubuntu
RUN apt-get update -y \
&& apt-get install -y wget \
&& wget -O netselect.deb http://http.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_`dpkg --print-architecture`.deb \
&& dpkg -i netselect.deb \
&& rm netselect.deb \
&& sed -r -i -e "s#http://(archive|security)\.ubuntu\.com/ubuntu/?#$(netselect -v -s1 -t20 `wget -q -O- https://launchpad.net/ubuntu/+archivemirrors | grep -P -B8 "statusUP|statusSIX" | grep -o -P "http://[^\"]*"`|grep -P -o 'http://.+$')#g" /etc/apt/sources.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment