Ch11 exercise diamol/jenkins image out of date
Exercise Section 11.2 the infrastructure containers for jenkins (and probably GOGs)
Problem The jenkins containers is out of date with a lot of dependency errors so the default diamol job is never created. Gogs could also be out of date as well
Docker version PS C:\WINDOWS\system32> docker version Client: Cloud integration: v1.0.29 Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:08:16 2022 OS/Arch: windows/amd64 Context: default Experimental: true
Server: Docker Desktop 4.15.0 (93002) Engine: Version: 20.10.21 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 3056208 Built: Tue Oct 25 18:00:19 2022 OS/Arch: linux/amd64 Experimental: true containerd: Version: 1.6.10 GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
Code version
Please run git log -n 1 and paste the output.
Administrator@GALVATRON MINGW64 /c/docker/diamol (master)
$ git log -n 1
commit c8fd9a888d1a0b3d606af1b01dbe265de1cd4a02 (HEAD -> master, origin/master)
Author: Brian XXXX [email protected]
Date: Sat Jan 7 13:03:47 2023 -0500
Brian's custom additions
Additional context I realize keeping the current images up-to-date is probably not a long term solution. So instead i am trying to rebuild your example with the jenkins/jenkins and gogs/gogs official images. I was able to get the jenkins container to see the GOGs git repo. However i have two issues:
-
On the jenkins page, i cannot use the http://localhost:3000/diamol/diamol.git. I have to use the real IP address of Gogs repo. (How do the containers know how to translate localhost to my win10 IP address? i did edit my host file on my host and made the docker engine edit).
-
More significant, I created a jenkins pipeline script from SCM pointing to Gogs repo (by IP address), but launching the first verify.bat script keeps returning "docker: not found error". Suggestions on google keep saying install "docker in your jenkins container" or ensure you have the PATH variable set with your shell path (which if im suppose to use my host doesn't make sense to me). I also have the docker plugins installed. Puzzled why it won't use my win10 powershell to launch the first verify script.
Hoping you can provide some high level manual steps to help me build your example and get it going using the jenkins and gogs images and what i could be missing.
Thanks very much for your time. Brian
I have similar problem.
Ok so I think I was able to fix this. After you login to Jenkins and go to the notifications bell on the upper right it will show you that the plugins failed to load due to running an old version of Jenkins. It lists each plugin that fails and tells you the minimum version of Jenkins to run. I went through each plugin and the highest version was 2.319.1, so I did the following:
- Open
diamol\images\jenkins\linux\Dockerfileand changedARG JENKINS_VERSION="2.263.4"toARG JENKINS_VERSION="2.319.1". - Built a new image of Jenkins.
docker image build --tag jeff-jenkins .(I probably could have called itdiamol/jenkins:v2) - Updated
diamol\ch11\exercises\infrastructure\docker-compose.ymlto use my image of jenkins.image: jeff-jenkins. - Start the app
docker-compose -f docker-compose.yml -f docker-compose-linux.yml up -d
Now when I login to jenkins the job is there. Hope this helps.
wow i had no idea that images folder was even there. Is that folder there just for reference placed by the author? Because when you run the docker-compose.yml file, i assume it's pulling the image from the internet since you see the progress bar (and i don't see how any of the docker-compose files know that folder even exists)
i tried out your suggestion and built a new image locally with that change, and it works! Thanks for sharing @Jeffrey!
I also just figured out an alternative workaround solution using the official jenkins and gogs docker hub images:
- Edit the existing compose file to use the latest jenkins/jenkins and gogs/gogs container
- Add a volumes section under the jenkins service to create a communication socket with your host machine using "/var/run/docker.sock:/var/run/docker.sock"
- Explanation by this guy https://www.youtube.com/watch?v=sUy9C1bY3gQ&ab_channel=TomGregory
- Then install Docker inside of the jenkins/jenkins container according to https://www.fosslinux.com/49959/install-docker-on-debian.htm
- Remove the sudos in the commands from the article as you don't need them
- This allows you to use docker-cli inside of the jenkins containers to communicate with the docker daemon. This is what people seem to say is the best way if you want use jenkins to be able to spin up containers.
- Then install Docker Compose using apt-get install docker-compose-plugin (apparently doesn't come with the default packages)
- Add an alias for the command docker-compose as it is deprecated in the new version (it's "docker compose" now)
- Use: echo 'docker compose --compatibility "$@"' | tee -a /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
This took a long time to figure out but it seems to work as well...also the latest jenkins 2.385 is a lot nicer. It shows you a graphical table of the pipeline jobs as they are running...and you can click each stage to see the status and console output of each stage which is pretty nice. Hope this helps if anyone finds it useful.
Glad to help. I think I will try your solution for all the features you mentioned. Thanks for sharing the steps and research, @brian4ko!
As @JeffreyScannell said, I checked the operation on Intel Mac after Jenkins change version. As of the date of writing the comment (2023-09-01), Jenkins version used 2.346.1. However, it did not work properly on the m1 Mac. Please refer to it.
@alsdud154 I change Jenkins version to 2.361.1
You need to change code about OpenJDK that diamol used is deprecated. You can check it at https://github.com/docker-library/openjdk
So I edit code about jdk using https://github.com/corretto/corretto-docker/blob/137b6ef028776de9f49e638a072a9e478fc60257/11/jdk/alpine/3.15/Dockerfile
After that docker image build --tag alsdud-jenkins .
And use alsdud-jenkins image instead diamol/jenkins
You can check Dockerfile in pr https://github.com/sixeyed/diamol/pull/64