nixpkgs/pkgs/build-support/docker/pull.sh

37 lines
835 B
Bash
Raw Normal View History

source $stdenv/setup
2017-05-26 18:06:24 +02:00
mkdir -p /var/lib/docker
mkfs.ext4 /dev/vda
mount -t ext4 /dev/vda /var/lib/docker
2017-05-26 18:06:24 +02:00
modprobe virtio_net
dhclient eth0
2017-05-26 18:06:24 +02:00
mkdir -p /etc/ssl/certs/
cp "$certs" "/etc/ssl/certs/"
2017-05-26 18:06:24 +02:00
# from https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
cd /sys/fs/cgroup
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
mkdir -p $sys
if ! mountpoint -q $sys; then
if ! mount -n -t cgroup -o $sys cgroup $sys; then
rmdir $sys || true
fi
2017-05-26 18:06:24 +02:00
fi
done
2017-05-26 18:06:24 +02:00
# run docker daemon
dockerd -H tcp://127.0.0.1:5555 -H unix:///var/run/docker.sock &
2017-05-26 18:06:24 +02:00
until $(curl --output /dev/null --silent --connect-timeout 2 http://127.0.0.1:5555); do
printf '.'
sleep 1
done
2017-05-26 18:06:24 +02:00
rm -r $out
2017-05-26 18:06:24 +02:00
docker pull ${imageId}
docker save ${imageId} > $out