Created
June 30, 2016 22:28
-
-
Save dmcgowan/f01445186e59d19381d3bc7ca0c5324c to your computer and use it in GitHub Desktop.
Test docker run on fresh device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env sh | |
# testrun.sh runs a docker container on a fresh device | |
# to test for errors mounting and running a container. | |
# | |
# Usage: | |
# sh testrun.sh <device> <storage driver> <image> [<run arg>, ...] | |
# | |
# How to use: | |
# $ fallocate -l 2GB testvolume | |
# $ device=$(sudo losetup -f --show ./testvolume) | |
# $ sudo mkfs -t xfs -m crc=0 -n ftype=0 -f $device | |
# $ sudo sh testrun.sh $device overlay ubuntu:latest /bin/echo "Works just fine!" | |
tmpdir=$(mktemp -d) | |
device=$1 | |
graphdriver=$2 | |
shift | |
shift | |
mount $device $tmpdir | |
echo "Mounted $device to $tmpdir" | |
echo "Starting docker engine using $graphdriver storage driver" | |
docker daemon -D -s $graphdriver -g $tmpdir > /tmp/dockertestlog.txt 2>&1 & | |
sleep 10 | |
docker run $@ | |
kill $(cat /var/run/docker.pid) | |
sleep 2 | |
umount $tmpdir | |
rmdir $tmpdir | |
echo "Unmounted and remove $tmpdir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment