I'm trying to run a fault tolerant Jenkins in a docker swarm using the following command:
docker service create --replicas 1 --name jenkins -p 8080:8080 -p 50000:50000 --mount src=/home/ubuntu/jenkins_home,dst=/var/jenkins_home jenkins:alpine
But checking the service status and containers running I see that the replicas stay in 0.
ubuntu@ip-172-30-3-81:~$ docker service create --replicas 1 --name jenkins -p 8080:8080 -p 50000:50000 --mount src=/home/ubuntu/jenkins_home,dst=/var/jenkins_home jenkins:alpine
14kwt6xoxorn62irnv9y2wm3r
ubuntu@ip-172-30-3-81:~$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
14kwt6xoxorn jenkins 0/1 jenkins:alpine
87ovyhkparou helloworld 1/1 alpine ping docker.com
ubuntu@ip-172-30-3-81:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
739f8180c989 alpine:latest "ping docker.com" 21 minutes ago Up 21 minutes helloworld.1.4rz08cygb7whjmzm3922h0bfb
I've tried running Jenkins in a container (without swarm) and it works perfectly, and also the swarm service example from docker's tutorial also works perfectly.
What is preventing the Jenkins service from running?
The problem was with the parameters passed to the --mount option.
I was trying to pass the source as a host directory, when I should be passing a docker volume according to docker swarm documentation. To correct the problem I did the following.
As a side-note, I think it would be useful for docker to show an error message when a mount source could not be found.