Skip to content

Instantly share code, notes, and snippets.

@samuelkarp
Created November 30, 2015 18:56
Show Gist options
  • Save samuelkarp/cab8f8bfd50a99df8959 to your computer and use it in GitHub Desktop.
Save samuelkarp/cab8f8bfd50a99df8959 to your computer and use it in GitHub Desktop.
Docker 1.9.1 on Ubuntu 14.04 with devicemapper
#!/bin/bash
TESTDIR=/opt/test
mkdir -p ${TESTDIR}
cat >${TESTDIR}/runner.sh << 'EORUNNER'
#!/bin/bash
curl https://get.docker.com | sh
/bin/bash test.sh > test.out
EORUNNER
cat >${TESTDIR}/run-only.sh << 'EORUNONLY'
#!/bin/bash
TIME=$(which time)
TIMEFILE="time-nginx.out"
MAXTIME="0.00"
total_containers=1000
for i in $(seq 1 ${total_containers}); do
echo "Running ${i}/${total_containers}"
${TIME} -o "${TIMEFILE}" -f '%e' sudo docker run nginx echo "hello, container"
nginx_time=$(cat ${TIMEFILE})
echo "Ran in ${nginx_time}"
if (( $(echo "${nginx_time} >= ${MAXTIME}" | bc -l) )); then
echo "New maxtime ${nginx_time} :("
MAXTIME="${nginx_time}"
fi
done
echo "Ran ${total_containers}; the longest-running container took ${MAXTIME} to run."
EORUNONLY
cat >${TESTDIR}/run-delete.sh << 'EORUNDELETE'
#!/bin/bash
TIME=$(which time)
TIMEFILE="time-busybox.out"
MAXTIME="0.00"
total_containers=1000
for i in $(seq 1 ${total_containers}); do
echo -n "Running ${i}/${total_containers}: "
container=$(sudo docker run -d busybox sleep 1)
echo "${container}"
sudo docker stop "${container}"
echo "Removing ${container}"
${TIME} -o "${TIMEFILE}" -f '%e' sudo docker rm "${container}"
busybox_time=$(cat ${TIMEFILE})
echo "Removed in ${busybox_time}"
if (( $(echo "${busybox_time} >= ${MAXTIME}" | bc -l) )); then
echo "New maxtime ${busybox_time} :("
MAXTIME="${busybox_time}"
fi
done
echo "Removed ${total_containers}; the longest removal took ${MAXTIME}"
EORUNDELETE
cat >${TESTDIR}/test.sh << 'EOTEST'
#!/bin/bash
sudo service docker stop
echo 'DOCKER_OPTS="-s devicemapper"' | sudo tee -a /etc/default/docker
sudo rm -rf /var/lib/docker
sudo service docker start
sudo docker version
sudo docker info
echo "Preparing images"
sudo docker pull nginx
sudo docker pull busybox
echo "Starting run-only.sh"
RUN_ONLY_OUTPUT="run-only.out"
/bin/bash ./run-only.sh &>"${RUN_ONLY_OUTPUT}" &
RUN_ONLY_PID="$!"
echo "Starting run-delete.sh"
RUN_DELETE_OUTPUT="run-delete.out"
/bin/bash ./run-delete.sh &>"${RUN_DELETE_OUTPUT}" &
RUN_DELETE_PID="$!"
wait "${RUN_ONLY_PID}"
RUN_ONLY_RC="$?"
wait "${RUN_DELETE_PID}"
RUN_DELETE_RC="$?"
cat <<EOS
===============================================================================
run-only.sh output
===============================================================================
$(cat ${RUN_ONLY_OUTPUT})
===============================================================================
run-delete.sh output
===============================================================================
$(cat ${RUN_DELETE_OUTPUT})
EOS
EOTEST
cd ${TESTDIR}
/bin/bash runner.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment