Deploying Jenkins Using Docker

  1. Pull the Jenkins Docker image.
docker pull jenkins/jenkins
  1. Set up a persistent storage directory on the host and adjust permissions.
mkdir -p /var/jenkins_data
chmod 777 /var/jenkins_data
  1. Launch a Jenkins container with custom configurations.
    • -d runs the container in detached mode.
    • -p 10240:8080 maps the container's Jenkins web interface port.
    • -p 10241:50000 maps the agent communication port.
    • -v /var/jenkins_data:/var/jenkins_home mounts the host directory for Jenkins data persistence.
    • -v /etc/localtime:/etc/localtime synchronizes the container's timezone with the host.
    • --name jenkins_instance assigns a name to the container.
docker run -d -p 10240:8080 -p 10241:50000 -v /var/jenkins_data:/var/jenkins_home -v /etc/localtime:/etc/localtime --name jenkins_instance jenkins/jenkins
  1. Verify that the container is running.
docker ps -l
  1. Check the container logs for any startup issues.
docker logs jenkins_instance
  1. Configure an update center mirror for faster plugin downloads. Navigate to the mounted directory and modify the update center configuration file.
cd /var/jenkins_data
sed -i 's|https://updates.jenkins.io/update-center.json|https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json|' hudson.model.UpdateCenter.xml
  1. Access the Jenkins web interface by navigating to http://<server_ip>:10240 in a browser.

  2. Retrieve the initial administrator password from the persistent storage.

cat /var/jenkins_data/secrets/initialAdminPassword

Enter the dislpayed password in the Jenkins setup wizard to proceed with configuraton.

Tags: docker Jenkins deployment ci-cd containerization

Posted on Thu, 14 May 2026 13:26:49 +0000 by alexdoug