Preparation
Create configuration file
cd /usr/local/docker/jenkins
mkdir data
cat > data/log.properties <<EOF
handlers=java.util.logging.ConsoleHandler
jenkins.level=FINEST
java.util.logging.ConsoleHandler.level=FINEST
EOF
ready
Start installing Jenkins
- Pull the Jenkins image from the repository
Do not use directly here: docker pull jenkins
, so that the downloaded image will always report missing plug-ins after startup. At present, I have not found a way to solve it. Of course, you can try it.
docker pull jenkins/jenkins
- Start the Jenkins container
Jenkins image ID via:docker images
get image ID
docker run --name jenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS="-Djava.util.logging.config.file=/var/jenkins_home/log.properties" -v /usr/local/docker/jenkins/data:/var/jenkins_home --restart=always -itd jenkins镜像ID
- Verify whether the Jenkins container is started successfully.
After executing the following command, it is correct if there is a new container service named jenkins
docker ps
- Open port 8080 on the firewall for public network access
(1) Check the firewall status: firewall-cmd --state
(2) Check the open ports: firewall-cmd --list-ports
(3) Open the firewall ports: firewall-cmd --zone=public --add-port=8080/tcp --permanent
(4) Reload the firewall to make the newly opened ports take effect:firewall-cmd --reload
- Check whether port 8080 is opened successfully
firewall-cmd --zone=public --query-port=80/tcp
- Use the external network to access Jenkins test
http://server address: 8080
Finish