I was thinking a lot, what shoudl be next post. I already started draft of usage of Docker advanced topics (I will post it in the future). I wanted to create real life example. I came up with idea, to connect Docker usage and Jenkins learning. I realize despite Jenkins simiplicity, in right hands, it is very powerfull tool.
I have plan to divide Jenkins post in few step real life usage.
Plan:
Chapter 1. Install Jenkins (with Docker)
Chapter 2. Create Freestyle Jobs
Chapter 3. CI/CD project
Chapter 1. Install Jenkins
Before we begin, I need set reservation, Docker need to installed.
Before installation, I woudll like to confirm, that Jenkins is not installed.
Command docker image ls -all and docker ps, show status before installation.
One of core feature in Docker is networks. It is 5 type of Docker network. For Jenkins we will user network type: bridge.(1)
Containers in the network can communicate with each other using their own IP addresses and DNS names, but they’re isolated from those outside the network(2)(3).
docker network create jenkins
Dockerfile
FROM jenkins/jenkins:2.492.2-jdk17
USER root
RUN apt-get update && apt-get install -y lsb-release ca-certificates curl && \
install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
chmod a+r /etc/apt/keyrings/docker.asc && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/debian $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \
| tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && apt-get install -y docker-ce-cli && \
apt-get clean && rm -rf /var/lib/apt/lists/*
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
Dockerfile build command:
docker build -t myjenkins-blueocean:2.492.2-1 .
Initial run localhost:8080, show information how unlock Jenkis.
Jenkins installation was completed.
Docs:
1. https://www.jenkins.io/doc/book/installing/docker/
2. https://spacelift.io/blog/docker-networking
3. https://docs.docker.com/engine/network/drivers/bridge/
PS. Jenkins can be made in Docker compose:
https://dev.to/msrabon/step-by-step-guide-to-setting-up-jenkins-on-docker-with-docker-agent-based-builds-43j5











No comments:
Post a Comment