Create a Directory cd /usr/local/docker/ mkdir jenkins-docker cd jenkins-docker Create Dockerfile vi Dockerfile # The following is the file content FROM jenkins/jenkins:lts USER root RUN mkdir -p /usr/local/ && \ cd /usr/local/ && \ curl -fsSL https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz > /usr/local/apache-maven-3.6.3-bin.tar.gz && \ tar xzf /usr/local/apache-maven-3.6.3-bin.tar.gz -C /usr/local/ && \ rm -rf /usr/local/apache-maven-3.6.3-bin.tar.gz && \ ln -s /usr/local/apache-maven-3.6.3/bin/mvn /bin/mvn && \ ln -s /usr/local/apache-maven-3.6.3/bin/mvnyjp /bin/mvnyjp && \ export PATH=/usr/local/apache-maven-3.6.3/bin:$PATH USER jenkins Build the image docker build -t jenkins-jiacs:lts . View Docker's Group ID on the host cat /etc/group | grep docker # [root@localhost jenkins-docker]# cat /etc/group | grep docker # docker:x:994: # My value is 994, depending on the actual value Start the Jenkins container (start with the docker command line) # Before starting the container, create the /usr/local/docker/jenkins-docker/data folder and grant permissions # /usr/local/docker/jenkins-docker/config/settings.xml This file is provided by itself (private server and other information can be customized) mkdir data chmod -R 777 data docker run -d -p 8080:8080 -p 50000:50000 \ -v /usr/local/docker/jenkins-docker/data:/var/jenkins_home \ -v /etc/localtime:/etc/localtime:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /etc/docker:/etc/docker \ -v /usr/bin/docker:/usr/bin/docker \ -v /usr/local/bin/docker-compose:/usr/local/bin/docker-compose \ -v /usr/local/docker/jenkins-docker/config/settings.xml:/usr/local/apache-maven-3.6.3/conf/settings.xml \ --group-add=994 \ --name my-jenkins \ jenkins-jiacs:lts # illustrate: # 1. -v /usr/local/docker/jenkins-docker/data:/var/jenkins_home =》Persist Jenkins data# 2. -v /etc/localtime:/etc/localtime:ro =》Set the Jenkins container time to be consistent with the host# 3. -v /etc/docker:/etc/docker =》The docker used in the Jenkins container is the docker installed on the host, ensuring that the service deployed by Jenkins is started in the host# 4. -v /usr/local/bin/docker-compose:/usr/local/bin/docker-compose If the host has docker-compose installed, you can add the data volume if the Jenkins container needs to use it# -v /usr/local/docker/jenkins-docker/config/settings.xml:/usr/local/apache-maven-3.6.3/conf/settings.xml # --group-add=994 Set the user group of the started container to the user group of docker in the host machine, ensuring that the Jenkins container has the authority to operate the docker command of the host machine Start the Jenkins container (docker-compose start) cd /usr/local/docker/jenkins-docker vi jenkins-docker.yaml version: '2' # Do not modify the version number, some versions do not support the group_add parameter services: Jenkins: image: 'jenkins-jiacs:lts' container_name: my-jenkins # restart: always ports: - '8080:8080' - '50000:50000' group_add: - 994 volumes: - ./data:/var/jenkins_home - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/var/run/docker.sock - /etc/docker:/etc/docker - /usr/bin/docker:/usr/bin/docker - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose - ./config/settings.xml:/usr/local/apache-maven-3.6.3/conf/settings.xml start up docker-compose -f jenkins-docker.yaml up -d View Container docker ps Entering the container docker exec -it 0d8b70ba5cec bash # View the Jenkins initial password (executed in the container) cat /var/jenkins_home/secrets/initialAdminPassword Open the browser and access the Jenkins service
Change Jenkins time zone System Management > Script Command Line, enter the following command and click [Run] System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'Asia/Shanghai') Installation Complete This is the end of this article about installing Jenkins with docker-compose. For more information about installing Jenkins with docker-compose, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Pure CSS3 to achieve mouse over button animation Part 2
>>: Using iframe techniques to obtain visitor QQ implementation ideas and sample code
As components become more detailed, you will enco...
Table of contents question Server layer and stora...
Table of contents Initialize computed Dependency ...
Table of contents Some basic instructions 1. Chec...
tomcat official website tomcat is equivalent to a...
MySQL's CAST() and CONVERT() functions can be...
This article shares the specific code of js to ac...
In combination with the scenario in this article,...
There are three ways to create an image: creating...
Table of contents Vue monitor properties What is ...
1. First install the pagoda Installation requirem...
I was bored and suddenly thought of the implementa...
Preface I recently encountered a problem at work....
First of all, what is a font icon? On the surface...