Docker群中的Jenkins服务停留在0/1个副本中 [英] Jenkins service in Docker swarm stays at 0/1 replicas
问题描述
我正在尝试使用以下命令在Docker群中运行容错Jenkins:
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
但是检查服务状态和正在运行的容器后,我发现副本保持为0.
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
我已经尝试在容器中运行Jenkins(没有群集),并且效果很好,还有码头工人的教程也可以正常运行.
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.
是什么导致Jenkins服务无法运行?
What is preventing the Jenkins service from running?
推荐答案
问题在于传递给--mount选项的参数.
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
作为一个旁注,我认为当找不到挂载源时,docker显示一条错误消息会很有用.
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.
这篇关于Docker群中的Jenkins服务停留在0/1个副本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!