Skip to content

Instantly share code, notes, and snippets.

@4383
Forked from bogdando/docker_vs_podman_run.sh
Created February 1, 2019 10:54
Show Gist options
  • Save 4383/99d1f0cc2162dcc1f4d16d73c933f7b5 to your computer and use it in GitHub Desktop.
Save 4383/99d1f0cc2162dcc1f4d16d73c933f7b5 to your computer and use it in GitHub Desktop.
Comparing the time it takes to launch containers concurrently for docker and podman runtimes
#!/bin/bash
set -e
containers_total=${1:-100}
containers_concur=${2:-10}
container_image=${3:-docker.io/library/busybox}
podman pull $container_image
docker pull $container_image
rm -f bench-jobs.txt
podman rm -f $(sudo podman ps -qa --filter name=cbench)||:
docker rm -f $(sudo docker ps -qa --filter name=cbench)||:
for i in $(seq 1 $containers_total); do
cmd="run -d --name cbench$i -v /sys/fs/cgroup:/sys/fs/cgroup -m 100M --cpus=1 --cpu-shares=100 $container_image sleep $(( containers_concur * 2 ))"
echo "$cmd" >> bench-jobs.txt
done
set -x
exec 3>&1
{ time cat bench-jobs.txt | xargs -r -n1 -P $containers_concur -I{} bash -c "echo docker {}; { time docker {} 1>&3; } 2>&1" 1>&3; } 2>&1
{ time cat bench-jobs.txt | xargs -r -n1 -P $containers_concur -I{} bash -c "echo podman {}; { time podman {} 1>&3; } 2>&1" 1>&3; } 2>&1
exec 3>&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment