Jenkins service in Docker swarm stays at 0/1 replicas

浪子不回头ぞ 提交于 2019-12-12 09:48:54

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/44253396/jenkins-service-in-docker-swarm-stays-at-0-1-replicas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!