Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Self-Host Jenkins with Docker and Configuration as Code

A practical guide to running Jenkins in Docker with durable /var/jenkins_home storage, version-controlled JCasC YAML, secure Docker build options, and tested upgrade and recovery procedures.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The dependable pattern is a Jenkins controller running from the official jenkins/jenkins image, with /var/jenkins_home on durable storage and controller settings loaded from version-controlled YAML through Jenkins Configuration as Code (JCasC). Pin the Jenkins image and plugin versions, restrict access to the Docker daemon, and test upgrades against a copy of the Jenkins volume before changing production.

What you are building

A Docker deployment separates Jenkins into a replaceable controller container and a persistent state directory. The container can be recreated when you upgrade the image; the state must survive that replacement. The official Docker image is the supported starting point and contains the current Jenkins long-term support (LTS) release.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The durable boundary is /var/jenkins_home. Jenkins stores jobs, build records, plugins, credentials metadata, and configuration there. Treat that path like a database: back it up, control who can write it, and never assume that deleting the container deletes nothing important.

JCasC adds a second layer of control. It loads controller settings from YAML when Jenkins starts, so security configuration, nodes, global tools, and other controller-level settings can be reviewed as code. Keep pipeline logic in Jenkinsfile files with the application repositories; use JCasC for the controller.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Requirements and sizing

The Jenkins project lists 256 MB of RAM and 1 GB of drive space as minimums. Its Docker guidance recommends at least 10 GB when Jenkins runs in a container. For a small team, the same guidance recommends 4 GB or more of RAM and 50 GB or more of drive space. Those figures are capacity floors, not performance guarantees: build workloads, retained artifacts, concurrent agents, and Docker layers can require substantially more.

Deployment concern Minimum or recommendation What to plan for
Memory 256 MB minimum 4 GB or more for a small team, with additional memory for builds and agents
Disk 1 GB minimum 10 GB minimum recommended for a Docker container; 50 GB or more for a small team
Persistent state /var/jenkins_home A named volume or host storage with tested backups
Container image Official jenkins/jenkins image An immutable, tested LTS tag or digest under change control
Configuration JCasC YAML A version-controlled file, directory, or URL supplied through CASC_JENKINS_CONFIG

Install Docker Engine or Docker Desktop on a supported host and make sure the account that will operate Jenkins can run the required Docker commands. Protect the host itself: anyone who can administer the Docker daemon can generally influence every container on it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create durable Jenkins storage

Use a named volume

A named volume is the simplest portable choice. Create it before the first container:

docker volume create jenkins_home

Docker then mounts that volume at the Jenkins state path. A named volume is not automatically a backup; it is only storage managed by Docker.

Use a host directory when you need host-level tooling

A host directory can simplify filesystem snapshots, monitoring, or storage-policy integration:

sudo mkdir -p /srv/jenkins_home
sudo chown -R 1000:1000 /srv/jenkins_home

The container image normally runs Jenkins as a non-root user. Verify the UID and permissions for the exact image you have selected before changing ownership, and do not make the directory world-writable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Back up before the first upgrade

Stop Jenkins or otherwise quiesce writes before making a filesystem-level backup. For a named volume, one straightforward archive method is:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
docker run --rm 
  -v jenkins_home:/data:ro 
  -v "$PWD":/backup 
  busybox tar czf /backup/jenkins_home-$(date +%Y%m%d).tar.gz -C /data .

Store the archive outside the Docker host as well. Periodically restore it to a test volume and start a disposable controller; a backup that has never been restored is an assumption, not a recovery plan.

Start the Jenkins controller

Run the official image

The following command illustrates the standard layout. Replace the example image tag with the exact LTS tag or digest that you have tested and recorded:

docker run -d 
  --name jenkins 
  --restart=on-failure 
  -p 8080:8080 
  -p 50000:50000 
  -v jenkins_home:/var/jenkins_home 
  jenkins/jenkins:lts-jdk17

Port 8080 is the web interface in the default image. Port 50000 is the traditional inbound agent port; publish it only if you actually use inbound agents, and restrict both ports with the host firewall or a private network. A reverse proxy can terminate HTTPS and expose only the proxy to the public network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Complete the first-run wizard

  1. Open the controller on the published web port.
  2. Read the initial administrator password from the container logs or the file Jenkins identifies during setup.
  3. Install only the plugins you need, or use a controlled image with a pinned plugin list.
  4. Create the administrator account and record how it will be recovered.
  5. Set the Jenkins URL to the stable address agents and webhooks will use.

Do not treat the setup wizard as your long-term configuration source. Once the controller is reachable, move repeatable settings into JCasC and source control.

Install and enable JCasC

Build a controlled Jenkins image

The most reproducible approach is to build from the official image and install a pinned plugin set. For example, keep a plugins.txt file beside this Dockerfile:

FROM jenkins/jenkins:lts-jdk17

COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt

COPY casc_configs /usr/share/jenkins/ref/casc_configs
ENV CASC_JENKINS_CONFIG=/usr/share/jenkins/ref/casc_configs/jenkins.yaml

Pin the JCasC plugin and every other plugin in plugins.txt to versions you have tested with the selected Jenkins LTS image. Build this image in your normal CI process and retain the image digest used in each environment.

Mount JCasC files into an existing image

If you are not building a custom image yet, install the JCasC plugin through Jenkins’ plugin manager, then mount a read-only configuration directory and set the environment variable:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
docker run -d 
  --name jenkins 
  --restart=on-failure 
  -p 8080:8080 
  -v jenkins_home:/var/jenkins_home 
  -v /opt/jenkins-casc:/opt/jenkins-casc:ro 
  -e CASC_JENKINS_CONFIG=/opt/jenkins-casc/jenkins.yaml 
  jenkins/jenkins:lts-jdk17

CASC_JENKINS_CONFIG accepts a single YAML file, a directory, or a URL. When it points to a directory, JCasC recursively scans that directory for YAML files. A directory is useful when you separate security, tools, nodes, and global settings into independently reviewed files.

Start with a harmless configuration

Use a small file to verify that JCasC is loading before managing security or credentials:

jenkins:
  systemMessage: "This controller is managed with Jenkins Configuration as Code."

Restart the controller, inspect the startup log for JCasC messages, and confirm that the system message appears. If the message does not appear, check the path inside the container, file permissions, YAML indentation, and whether the JCasC plugin is installed in the image that actually started.

Organize the configuration repository

A practical repository keeps deployment, plugin, and controller configuration together while leaving application pipelines in their own repositories:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
jenkins-infrastructure/
├── Dockerfile
├── plugins.txt
├── casc_configs/
│   ├── jenkins.yaml
│   ├── security.yaml
│   ├── tools.yaml
│   └── nodes.yaml
└── compose.yaml

Review changes to the security realm, authorization strategy, credentials references, agents, and global tools as carefully as application code. Require a second administrator to review changes that could grant access or change where secrets are used.

Keep secrets out of unsafe YAML

JCasC can configure credentials and security, but putting plaintext secrets in a repository or interpolating them in an unprotected context can expose them. Prefer the secret store available in your environment, inject values only through a protected mechanism, and ensure repository logs and build output cannot print them. Do not commit administrator passwords, private keys, registry tokens, or cloud credentials to the JCasC repository.

JCasC is an administrative boundary: only Jenkins administrators are able to create or update a Jenkins instance using configuration-as-code files. A malformed or malicious change to the security realm or authorization strategy can give users more permission than intended, including the ability to administer the controller. Protect the repository, the deployment credential, and the path from source control to the running container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Choose how builds reach Docker

Jenkins itself does not make a Docker build safe by default. A pipeline needs a Docker daemon, credentials for any registry, and an isolation model that matches the risk of the jobs you run.

Architecture How it works Main benefit Main risk or cost
Remote Docker daemon Jenkins connects to a separate daemon over a protected network endpoint. Build workloads are separated from the controller host. Requires network policy, authentication, TLS, and daemon lifecycle management.
Mounted Docker socket The controller or an agent receives the host’s Docker socket. Simple and fast to set up. Access to the socket is effectively powerful host control; a compromised job can affect the host.
Docker-in-Docker with TLS A dedicated docker:dind service runs a daemon and shares client certificates with the Jenkins job. Builds use an isolated daemon that can be discarded independently. Requires TLS certificates, storage planning, lifecycle automation, and careful privilege handling.

There is no universal best choice. Use a remote daemon when you already operate a secured build service, a socket only when the job trust model justifies host-level access, and Docker-in-Docker when you can operate its TLS and privileged-container requirements deliberately.

Docker-in-Docker details

The official Docker examples use a separate docker:dind service, shared certificate storage, and these client settings:

  • DOCKER_HOST identifies the daemon endpoint.
  • DOCKER_CERT_PATH points to the client certificate directory.
  • DOCKER_TLS_VERIFY enables certificate verification.

Mount the client certificate directory read-only into the Jenkins build environment. Keep the daemon’s data directory separate from /var/jenkins_home, rotate certificates, and restrict which jobs can use the Docker client. A DinD example is an architecture, not a requirement for every Jenkins installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the Docker Pipeline integration

Pipeline steps such as docker.image and docker.withDockerRegistry belong to the Docker Pipeline integration rather than the legacy Docker plugin. Install the current, compatible Pipeline components in the controlled plugin list and test them with your Jenkins LTS image.

pipeline {
  agent any
  stages {
    stage('Build image') {
      steps {
        script {
          def image = docker.build("registry.example/app:${env.BUILD_NUMBER}")
          docker.withDockerRegistry(
            credentialsId: 'registry-creds',
            url: 'https://registry.example'
          ) {
            image.push()
          }
        }
      }
    }
  }
}

The example assumes the selected agent can reach the configured Docker daemon and that the credential ID exists in Jenkins. Keep registry credentials scoped as narrowly as possible and avoid echoing them in shell commands.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Secure the controller and jobs

  • Expose the web and agent ports only on networks that need them; place public access behind HTTPS and an authenticated reverse proxy where appropriate.
  • Do not publish the Docker socket to untrusted jobs. A socket mount can provide more authority than the Jenkins administrator intended.
  • Separate controller administration from build execution. Use agents for resource-heavy or untrusted builds and keep controller executors disabled if your operating model permits.
  • Limit who can edit JCasC, plugin lists, deployment files, and the storage volume.
  • Review authorization strategy changes as security changes, not routine YAML edits.
  • Use short-lived or narrowly scoped registry and source-control credentials, and verify that build logs mask secret values.
  • Record the Jenkins image digest, plugin versions, JCasC commit, and backup identifier for every production deployment.

Upgrade without losing Jenkins

  1. Read the release notes for the target Jenkins LTS image and check plugin compatibility.
  2. Back up /var/jenkins_home and export the exact JCasC and plugin-list commits used by the current container.
  3. Restore the backup to a separate test volume and start the candidate image against that copy.
  4. Run representative jobs, verify agent connections, test credentials access without printing secrets, and confirm Docker builds.
  5. Drain or stop production builds, stop the old controller, and start the tested image with the original persistent volume.
  6. Check the startup log, web access, agents, scheduled jobs, and webhook delivery.
  7. Keep the previous image and the backup available until the new controller has passed your recovery window.

Replacing a container is safe only when the volume, image, plugin set, and configuration are treated as separate, versioned inputs. Never “upgrade” by deleting the volume and hoping JCasC recreates historical build data; JCasC configures the controller but does not replace all durable Jenkins state.

Troubleshoot common failures

Jenkins starts with an empty installation

Check that the new container mounts the same named volume or host directory at exactly /var/jenkins_home. Confirm the volume name with docker inspect jenkins, verify that the directory contains the expected files, and check ownership if you switched from a named volume to host storage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

JCasC changes are ignored

Verify that the JCasC plugin is installed, that CASC_JENKINS_CONFIG is present inside the container, and that the referenced file or directory is readable. For a directory, confirm that files have a YAML extension and that the mount is not hiding the directory you copied into the image. Read the startup log for parse or validation errors.

JCasC locks you out

Do not repeatedly edit production YAML blindly. Stop the controller, preserve the failed configuration and logs, restore the last known-good JCasC commit, and restart against the same volume. Test authorization and security-realm changes on a restored copy before redeploying them.

A pipeline cannot connect to Docker

Identify which daemon the job is supposed to use. Check DOCKER_HOST, certificate paths, and DOCKER_TLS_VERIFY for a TLS design; check socket permissions for a socket design; and verify network reachability and firewall rules for a remote daemon. The Jenkins controller’s ability to run Docker commands does not prove that the build agent can.

Builds fill the disk

Inspect both Jenkins data and Docker daemon storage. Build records, archived artifacts, workspaces, plugin files, and image layers may be on different filesystems. Set retention policies appropriate to your projects, clean unused Docker layers through the daemon’s documented procedures, and expand storage before the filesystem reaches 100 percent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Agents disconnect after a restart

Confirm that the agent connection method and port are still published, that the Jenkins URL is stable, and that firewall rules allow the direction of traffic your agents require. If you do not use inbound agents, remove the unused port instead of leaving it exposed.

Operational checklist

  • Official Jenkins LTS image selected and pinned to a tested tag or digest.
  • /var/jenkins_home stored on a named volume or controlled host directory.
  • Backups run on a schedule and have been restored in a test environment.
  • RAM and disk sized beyond the published minimums for the actual job load.
  • JCasC plugin and all other plugins pinned and built reproducibly.
  • CASC_JENKINS_CONFIG points to a reviewed file, directory, or approved URL.
  • Security realm, authorization, credentials, nodes, and tools reviewed as code.
  • Docker build architecture chosen explicitly, with TLS and network controls where required.
  • Registry credentials scoped and masked in logs.
  • Upgrade procedure tested against a copy of the production volume.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.