What is not included
Which Image?
Running Jenkins on docker is just about using the right image.When searching for "jenkins" on docker hub, the first result we get is an official image. But open it and it reads "This image has been deprecated in favor of the jenkins/jenkins:lts". This means, we need to use jenkins/jenkins:lts image.
Command
docker pull jenkins/jenkins:lts
And run it
docker run --detach \
--publish 8082:8080 --publish 50000:50000 \
--volume ~/docker/data/jenkins/jenkins_home:/var/jenkins_home \
--name jenkins \
jenkins/jenkins:lts
Flags explaination:
--detach: We shall run this image detached - i.e. the logs will not be printed on current terminal.
--publish: Jenkins exposes two set of ports - 8080 (tomcat) and 50000. We are trying to map it to local ports 8082 and 50000. We can use 8080. But in my case, I already have my java services running on 8080.
--volume: Jenkins keeps its config files in /var/jenkins_home. We are mapping it to a local folder.
--name: I shall call my container as "jenkins"
Open & Setup
First Job
- Click on "New Item" on left menu
- Enter item name. I chose "FirstJob"
- Select "Freestyle project"
- OK
- It opens configuration page for our new job.
- Scroll down to Build
- In "Add build step" dropdown, select "Execute Shell"
- In command just enter "uname -a". You could enter any command you want.
- Save
Linux bdc39ab786e1 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux
Conclusion
- I have no worry of installation and uninstallation leaving cruft behind.
- I can re-create containers as many times as I want.
- I can have multiple instances of same software on my system without interfering with each other.
Comments
Post a Comment