Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
for i in 1 2 3; do
dm rm -f swarm-$i
done
# swarm with 3 managers
scripts/dm-swarm.sh
# switch to swarm-1 env
eval $(dm env swarm-1)
# show list of docker nodes
docker node ls
mkdir -p docker/jenkins
docker service create --name jenkins \
-p 8082:8080 \
-p 5000:5000 \
-e JENKINS_OPTS="--prefix=/jenkins" \
--mount "type=bind,source=$PWD/docker/jenkins,target=/var/jenkins_home" \
--reserve-memory 300m \
jenkins:2.7.4-alpine
# check jenkins process
docker service ps jenkins
open "http://$(dm ip swarm-1):8082/jenkins"
scripts/dm-test-swarm.sh
# switch to swarm-test-1 env
eval $(dm env swarm-test-1)
docker node ls
docker node inspect swarm-test-1 --pretty
# ssh into swarm-test-1
dm ssh swarm-test-1
# create /workspace folder with full permissions (777)
sudo mkdir /workspace && sudo chmod 777 /workspace && exit
# create agent service
export USER=admin
export PASSWORD=admin
docker service create --name jenkins-agent \
-e COMMAND_OPTIONS="-master \
http://$(dm ip swarm-3):8082/jenkins \
-username $USER -password $PASSWORD \
-labels 'docker' -executors 5" \
--mode global \
--constraint 'node.labels.env == jenkins-agent' \
--mount "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock" \
--mount "type=bind,source=$HOME/.docker/machine/machines,target=/machines" \
--mount "type=bind,source=/workspace,target=/workspace" \
vfarcic/jenkins-swarm-agent
docker service ps jenkins-agent
# NO AGENT SERVICE DISPLAYED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.