Deploy Jenkins with Docker Compose on Windows: Handling Volume Mapping
This guide shows how to set up Jenkins on Windows using Docker Desktop and Docker Compose, create persistent volume directories, configure the compose file, adjust the update center to a domestic mirror, and retrieve the initial admin password.
To run Jenkins on a Windows machine with Docker Desktop, first create a jenkins_home directory for Jenkins data and a tool directory for installing JDK, Maven, etc., then place a docker-compose.yaml file in the same folder.
The compose file should contain the following content:
version: "3.6"
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins_test
restart: on-failure
privileged: true
user: root
ports:
- "38080:8080"
volumes:
- ./jenkins_home:/var/jenkins_home
- ./tool:/toolThe image used is jenkins/jenkins:lts. You can verify its availability with docker search jenkins. The container will be named jenkins_test, and port 8080 inside the container is mapped to host port 38080. On Windows Docker Desktop the volume mapping uses relative paths (e.g., ./jenkins_home), while a direct docker run command can use an absolute host path such as D:\SoftWare\jenkinshome:/var/jenkins_home.
Start the stack with: docker compose up -d If the container already exists, Docker Compose will reuse it without pulling a new image. After the command finishes, open http://localhost:38080 to reach the Jenkins UI, confirming that the jenkins_home volume is correctly mounted.
To speed up plugin downloads, edit the file jenkins_home/hudson.model.UpdateCenter.xml inside the mounted volume and replace the default update‑center URL with a domestic mirror, for example:
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.jsonAfter saving the change, restart the services:
docker compose down
docker compose up -dFinally, obtain the initial administrator password with:
docker exec -it jenkins_test cat /var/jenkins_home/secrets/initialAdminPasswordCopy the printed password, then proceed with plugin installation and further Jenkins configuration.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
The Dominant Programmer
Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
