cloud-provisioning icon indicating copy to clipboard operation
cloud-provisioning copied to clipboard

DevOps2.1: Jenkins CI/CD

Open white54503 opened this issue 10 years ago • 33 comments

I'm following along with the leanpub DevOps2.1 Toolkit. So far so good, but now the Jenkins CI/CD setup is proving difficult. With the swarm running:

Let’s create a Jenkins service.

1 mkdir -p docker/jenkins
2
3 docker service create --name jenkins \
4 -p 8082:8080 \
5 -p 50000:50000 \
6 -e JENKINS_OPTS="--prefix=/jenkins" \
7 --mount "type=bind,source=$PWD/docker/jenkins,target=/var/jenkins_home" \
8 --reserve-memory 300m \
9 jenkins:2.7.4-alpine
10
11 docker service ps jenkins

... docker service ps jenkins reports an error for the service ("invalid bind mount source, source path not found..."). However, the directory $PWD/docker/jenkins exists on local host.

I find a reference to this issue here: https://github.com/docker/docker/issues/25912. Still I can't resolve it.

Feels like I'm missing something obvious... Any help greatly appreciated. Thanks for sharing your work.

white54503 avatar Dec 01 '16 18:12 white54503

The command you posted should not be necessary in most cases. Which OS are you using (Windows, OSX, Linux)?

vfarcic avatar Dec 01 '16 22:12 vfarcic

I'm using Ubuntu 16.04. I just deleted the command I posted in my reply, because I couldn't replicate the result. For posterity, it was docker-machine ssh swarm-1 "mkdir -p docker/jenkins".

Version info:

jw@js-MS-001:~$ docker version
Client:
 Version:      1.12.3
 API version:  1.25
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:01:48 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0-rc2
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   1f9b3ef
 Built:        Wed Nov 23 17:40:58 2016
 OS/Arch:      linux/amd64

white54503 avatar Dec 01 '16 22:12 white54503

Docker Machine mounts user's directory from the host inside the VMs it creates. That allows us to share the files. However, that feature does not work in Docker Machine running on Linux. The easiest workaround is, for now, to remove the --mount argument. Later on, when we reach persistent storage, you'll see how to mount volumes more effectively.

The good news is that the problem will be fixed soon. Please see the issue #1376 for the discussion. Once the pull request #2122 is merged, you will be able to use automatic mounting on Linux.

vfarcic avatar Dec 01 '16 22:12 vfarcic

Awesome! Thank you so so much. Love the books.

white54503 avatar Dec 01 '16 22:12 white54503

Seems that https://github.com/docker/machine/pull/2122 is merged. Can you try it out and let me know if it works?

vfarcic avatar Jan 26 '17 12:01 vfarcic

I was able to work around this by creating a host mount in VirtualBox, auto-mounting it to "jenkins-agent "-labelled nodes at the time of swarm creation and finally mounting to Compose-created containers with the usual volume mount syntax.

I'll take the more direct approach when I find some free time and report back.

white54503 avatar Jan 27 '17 23:01 white54503

I have the same issue as above and I'm unable to mount the drive. I even skipped the same step in the previous chapter. I'm using Windows 10 and Docker ToolBox. I have attached my screen grab and also the command I ran

docker service create --name jenkins -p 8082:8080 -p 50000:50000 -e JENKINS_OPTS="--prefix=/jenkins" --mount "type=bind,source=/c/Users/rames/cloud-provisioning/docker/jenkins,target=/var/jenkins_home" --reserve-memory 300m jenkins:2.7.4-alpine

screen

rpchili avatar Feb 28 '17 22:02 rpchili

@rpchili Can you create Jenkins from a VM? That would be only a workaround until I figure out the cause of the problem.

vfarcic avatar Feb 28 '17 22:02 vfarcic

@vfarcic So, create jenkins from a VM and then follow the book??

rpchili avatar Feb 28 '17 22:02 rpchili

@rpchili Yes. That should (probably) avoid any problems cause by Windows.

vfarcic avatar Feb 28 '17 22:02 vfarcic

@rpchili Actually, now when I look at it again, running it from a VM will probably not fix the problem. I'll try to replicate it tomorrow and get back to you. If I do not manage to reproduce the same situation, I'll ask you for a chat session with screen sharing so that we can try to solve it together. Would that be OK?

vfarcic avatar Feb 28 '17 22:02 vfarcic

That would be extremely helpful. Thank You.

rpchili avatar Feb 28 '17 22:02 rpchili

@vfarcic Any luck with the issue? I cannot get past it. I'm Sorry to bother you again.

rpchili avatar Mar 01 '17 19:03 rpchili

@rpchili First of all, sorry for the late reply.

I managed to reproduce the problem and found the fix. Actually, the fix is in the book if you have a version from a few weeks ago (or newer). The comment is directly above the command that creates the service.

A note to Windows users

Git Bash has a habit of altering file system paths. To stop this, execute the following before running the code block.

export MSYS_NO_PATHCONV=1

Can you please remove the service, export the env. var and create the service again?

Please let me know if that fixed the problem.

Also, it would be useful to know where you both the book (LeanPub.com or Amazon.com) and whether it's paperback or eBook. In case it's paperback, please join http://slack.devops20toolkit.com and contact me on the private channel and I'll send you the latest eBook version (you'll also receive updates whenever I make them).

vfarcic avatar Mar 01 '17 21:03 vfarcic

Thank you for your response. Unfortunately I still have the same issue

image

Do you think I should ssh into swarm-1 machine and mount the drive first as you suggested in the previous chapter?

rpchili avatar Mar 01 '17 21:03 rpchili

Can you join http://slack.devops20toolkit.com/ and ping me there? We can take a look at it together. Windows is not one of my strong skills but I'm sure that we'll find a solution together.

vfarcic avatar Mar 01 '17 22:03 vfarcic

Can I join in 30min? Will you be available?

rpchili avatar Mar 01 '17 22:03 rpchili

I will :)

vfarcic avatar Mar 01 '17 22:03 vfarcic

Thank You. See you soon

rpchili avatar Mar 01 '17 22:03 rpchili

Using export MSYS_NO_PATHCONV=1 fixes mounting on Windows.

The problem @rpchili experienced is different than the original issue so I'm closing this ticket.

vfarcic avatar Mar 01 '17 22:03 vfarcic