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

37 lines
779 B
Bash
Raw Normal View History

source $stdenv/setup
2017-05-26 16:06:24 +00:00
mkdir -p /var/lib/docker
mkfs.ext4 /dev/vda
mount -t ext4 /dev/vda /var/lib/docker
2017-05-26 16:06:24 +00:00
modprobe virtio_net
dhclient eth0
2017-05-26 16:06:24 +00:00
mkdir -p /etc/ssl/certs/
cp "$certs" "/etc/ssl/certs/"
2017-05-26 16:06:24 +00: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 16:06:24 +00:00
fi
done
2017-05-26 16:06:24 +00:00
# run docker daemon
dockerd -H tcp://127.0.0.1:5555 -H unix:///var/run/docker.sock &
until docker ps 2>/dev/null; do
2017-05-26 16:06:24 +00:00
printf '.'
sleep 1
done
2017-05-26 16:06:24 +00:00
rm -r $out
2017-05-26 16:06:24 +00:00
docker pull ${imageId}
docker save ${imageId} > $out