Jenkins Installation: Automatic Jenkins Installation with Docker and JCasC
What Will You Learn in This Guide?
Manual Jenkins installations are time consuming and error prone.
In this guide, you will learn how to make Jenkins installation and configuration completely code-based using Docker and Jenkins Configuration as Code (JCasC).
At the end of the guide:
- The installation wizard is disabled,
- Necessary plug-ins are automatically installed,
- User and authorization are defined,
- Security configured
you will have a Jenkins server.
Preliminary Preparations
The following requirements must be met before you begin:
- A virtual server (VDS) with at least 2 GB RAM
- Docker installed on the server
- SSH access
Note:
tr1-node01.ornek.comorlocalhostis used in the examples.
1️⃣ Disabling the Setup Wizard
By default, Jenkins runs a setup wizard on first startup.
For automation this wizard must be disabled.
mkdir -p $HOME/projeler/jcasc
cd $HOME/projeler/jcasc
- These commands create the working directory for Jenkins configuration.
FROM jenkins/jenkins:latest
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false
- This setting permanently closes the Jenkins installation wizard.
docker build -t jenkins:jcasc .
- This command creates the custom Jenkins Docker image.
docker run --name jenkins --rm -p 8080:8080 jenkins:jcasc
- Jenkins is run via 8080 port.
2️⃣ Automatically Installing Required Jenkins Plugins
- In order to use Jenkins Configuration as Code, the necessary plugins are installed at the image stage.
ant:latest
configuration-as-code:latest
git:latest
matrix-auth:latest
workflow-aggregator:latest
authorize-project:latest
- This list:
-
JCasC configuration,
-
Authorization mechanisms,
-
Provides pipeline infrastructure.
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
- This step ensures automatic installation of Jenkins plugins.
3️⃣ Jenkins URL Configuration
- Jenkins system URL needs to be defined.
unclassified:
location:
url: http://tr1-node01.ornek.com:8080/
- This configuration allows Jenkins to know its own address.
ENV CASC_JENKINS_CONFIG /var/jenkins_home/casc.yaml
COPY casc.yaml /var/jenkins_home/casc.yaml
- This setting allows the JCasC file to be read by Jenkins.
4️⃣ Creating a Secure Admin User
- User information is not written to the configuration file.
- Environment variables are used instead.
jenkins:
securityRealm:
local:
allowsSignup: false
users:
- id: ${JENKINS_ADMIN_ID}
password: ${JENKINS_ADMIN_PASSWORD}
- This structure creates the admin user securely.
docker run --rm -p 8080:8080 \
--env JENKINS_ADMIN_ID=admin \
--env JENKINS_ADMIN_PASSWORD=GizliSifre123 \
jenkins:jcasc
5️⃣ Authorization and Security Configuration
- Authorization and build security are defined by JCasC.
authorizationStrategy:
globalMatrix:
permissions:
- "Overall/Administer:admin"
- "Overall/Read:authenticated"
security:
queueItemAuthenticator:
authenticators:
- global:
strategy: triggeringUsersAuthorizationStrategy
jenkins:
remotingSecurity:
enabled: true
- What does this configuration provide?
-
Full authority to admin user
-
Read permission for logged in users
-
Build operations work with the triggering user authority
-
Securing Agent-Controller communication
❓ Frequently Asked Questions (FAQ)
1. Is Jenkins data persistent?
No. Since --rm is used, the data is deleted when the container stops. Volume must be added for permanence.
-v jenkins_home:/var/jenkins_home
2. Should plugin versions be fixed? Version fixing is recommended in production environments.
3. Can it be used in a Kubernetes environment? Yes. This Docker image is compatible with Kubernetes.
Result
Jenkins installation with this guide:
Can be managed with code,
safe,
portable,
repeatable
has been made.
You can take your CI/CD processes to a professional level by using this configuration on high-performance VDS servers on the GenixNode infrastructure.

