Install Jenkins on Docker

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

  1. 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
  1. Start the Jenkins container
    Jenkins image ID via: docker imagesget 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
  1. 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
  1. 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

  1. Check whether port 8080 is opened successfully
    firewall-cmd --zone=public --query-port=80/tcp
  2. Use the external network to access Jenkins test
    http://server address: 8080

Finish

Guess you like

Origin blog.csdn.net/lu962820662/article/details/129394334