Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 25, 2019 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save vfarcic/9f9995f90c6b8ce136376e38afb14588 to your computer and use it in GitHub Desktop.
Save vfarcic/9f9995f90c6b8ce136376e38afb14588 to your computer and use it in GitHub Desktop.
cd cloud-provisioning
git pull
scripts/dm-swarm.sh
eval $(docker-machine env swarm-1)
docker node ls
mkdir -p docker/jenkins
docker service create --name jenkins \
-p 8082:8080 \
-p 50000:50000 \
-e JENKINS_OPTS="--prefix=/jenkins" \
--mount "type=bind,source=$PWD/docker/jenkins,target=/var/jenkins_home" \
--reserve-memory 300m \
jenkins/jenkins:2.161-alpine
docker service ps jenkins
open "http://$(docker-machine ip swarm-1):8082/jenkins"
cat docker/jenkins/secrets/initialAdminPassword
NODE=$(docker service ps \
-f desired-state=running jenkins \
| tail -n +2 | awk '{print $4}')
eval $(docker-machine env $NODE)
docker rm -f $(docker ps -qa \
-f label=com.docker.swarm.service.name=jenkins)
docker service ps jenkins
open "http://$(docker-machine ip swarm-1):8082/jenkins"
open "http://$(docker-machine ip swarm-1):8082/jenkins/pluginManager/available"
scripts/dm-test-swarm-2.sh
eval $(docker-machine env swarm-test-1)
docker node ls
eval $(docker-machine env swarm-test-1)
docker node inspect swarm-test-1 --pretty
docker-machine ssh swarm-test-1
sudo mkdir /workspace && sudo chmod 777 /workspace && exit
export USER=admin
export PASSWORD=admin
docker service create --name jenkins-agent \
-e COMMAND_OPTIONS="-master \
http://$(docker-machine ip swarm-1):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
open "http://$(docker-machine ip swarm-1):8082/jenkins/computer/"
docker-machine create -d virtualbox swarm-test-4
docker-machine ssh swarm-test-4
sudo mkdir /workspace && sudo chmod 777 /workspace && exit
TOKEN=$(docker swarm join-token -q worker)
eval $(docker-machine env swarm-test-4)
docker swarm join \
--token $TOKEN \
--advertise-addr $(docker-machine ip swarm-test-4) \
$(docker-machine ip swarm-test-1):2377
eval $(docker-machine env swarm-test-1)
docker node ls
docker service ps jenkins-agent
docker node update \
--label-add env=jenkins-agent \
swarm-test-4
docker service ps jenkins-agent
open http://$(docker-machine ip swarm-1):8082/jenkins/computer
scripts/dm-swarm-services-2.sh
eval $(docker-machine env swarm-1)
docker service ls
scripts/dm-test-swarm-services-2.sh
eval $(docker-machine env swarm-test-1)
docker service ls
open http://$(docker-machine ip swarm-1):8082/jenkins/configure
docker-machine ip swarm-1
eval $(docker-machine env swarm-1)
docker service ps go-demo
docker-machine rm -f \
swarm-1 swarm-2 swarm-3 \
swarm-test-1 swarm-test-2 \
swarm-test-3 swarm-test-4
@ankitarya10
Copy link

Following options works fine on virtualbox ( way its described here):
--mount "type=bind,source=$HOME/.docker/machine/machines,target=/machines" \

but it fails with invalid mount on aws nodes.

Also, even on virtualbox nodes I couldn't find any folder named /machines. From what I understand its mounted the same was as --mount "type=bind,source=/workspace,target=/workspace" . So, should there be a "machines" dir under "/".

A clarification is greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment