3

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?

nacho_dh
  • 1,847
  • 3
  • 18
  • 27
  • Did you check the logs? – Henry May 30 '17 at 04:29
  • I tried getting the logs doing "docker service logs jenkins" as this part of the docs explains, but "logs" doesn't seem like a valid command in that context. What would be the best way to get the service the logs to see why it's not even starting a container? – nacho_dh May 30 '17 at 04:54
  • can you try to check logs like `docker logs 14kwt6xoxorn` ? paste the output here.Seems like there may be a `--mount` directory path having issues. – chintan thakar May 30 '17 at 06:19
  • docker logs 14kwt6xoxorn returns "Error: No such container" because that's the service number, and the service isn't even starting a container apparently. But we are on the right track, I tried creating the Jenkins service without the volume mount and it worked. – nacho_dh May 30 '17 at 12:37

1 Answers1

3

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.

docker volume create --name jenkins_home 

docker service create --replicas 1 --name jenkins -p 8080:8080 -p 50000:50000 --mount source=jenkins_home,dst=/var/jenkins_home jenkins:alpine

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.

nacho_dh
  • 1,847
  • 3
  • 18
  • 27