Skip to content

Instantly share code, notes, and snippets.

@timjrobinson
Created July 2, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timjrobinson/3fc5cc8128cee6b4d0ff to your computer and use it in GitHub Desktop.
Save timjrobinson/3fc5cc8128cee6b4d0ff to your computer and use it in GitHub Desktop.
Spawn selenium docker containers on a host
#!/bin/bash
# Usage: ./run-selenium-container 9000 5 - Will create 5 selenium containers running on ports 9000, 9001, 9002, 9003, 9004
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
START_PORT=${1:-4444}
TOTAL_CONTAINERS=${2:-1}
for (( I = 0; I < $TOTAL_CONTAINERS; I++ )); do
PORT=$(($START_PORT + $I))
echo "Creating container on port $PORT"
CONTAINER_ID=$(sudo docker run -d --volume=/home/ubuntu/ci:/home/ubuntu/ci -it --privileged --name="selenium-$PORT" -p $PORT:4444 selenium/standalone-chrome:2.46.0)
sleep 5
sudo tail -f /var/lib/docker/aufs/diff/$CONTAINER_ID/var/log/supervisor/* > /var/log/selenium-container-$PORT.txt &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment