- Pull the Jenkins Docker image.
docker pull jenkins/jenkins
- Set up a persistent storage directory on the host and adjust permissions.
mkdir -p /var/jenkins_data
chmod 777 /var/jenkins_data
- Launch a Jenkins container with custom configurations.
-druns the container in detached mode.-p 10240:8080maps the container's Jenkins web interface port.-p 10241:50000maps the agent communication port.-v /var/jenkins_data:/var/jenkins_homemounts the host directory for Jenkins data persistence.-v /etc/localtime:/etc/localtimesynchronizes the container's timezone with the host.--name jenkins_instanceassigns 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
- Verify that the container is running.
docker ps -l
- Check the container logs for any startup issues.
docker logs jenkins_instance
- 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
-
Access the Jenkins web interface by navigating to
http://<server_ip>:10240in a browser. -
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.