Skip to content

Instantly share code, notes, and snippets.

@ik5
Created July 26, 2019 15:54
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 ik5/858d635a6b601b472790699803e3dc04 to your computer and use it in GitHub Desktop.
Save ik5/858d635a6b601b472790699803e3dc04 to your computer and use it in GitHub Desktop.
Creating 10 workers, takes the host ip using docker
#!/usr/bin/env bash
declare -i min=0
declare -i max=10
host=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
for (( c=min; c<max; c++ )) do
echo "Going to start worker # $c"
docker run\
-e "DOCKER_HOST=$host"\
-dit \
--name "worker-$c"\
local/worker:latest\
/bin/bash -c "worker -queue-number $c"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment