Detailed process of installing Jenkins-2.249.3-1.1 with Docker

Detailed process of installing Jenkins-2.249.3-1.1 with Docker

1. Install Docker

#1. Write the Docker installation script [root@ip-10-0-12-212 ~]# vim Ins_Docker.sh 
#!/usr/bin/bash
# Author:jh
# Time:2021-10-09 11:54:22
# Name:Ins_Docker.sh
# Version: 1.0
# Discription: To  
source /etc/init.d/functions

rely_software=(yum-utils device-mapper-persistent-data lvm2)

echo "-----------------#1. Detect system kernel version-----------------"
kernel_version=`uname -a |awk '{print $3}'|cut -d. -f1`
[ $kernel_version -ge 3 ] && action "The System Install Docker is ..." /usr/bin/true || action "The System Can not Install Docker is ...";exit
 
echo "-----------------#2. Install Docker dependent software-----------------"
for i in ${rely_software[*]}
do       
    rpm -q $i &>/dev/null
    if [ $? -eq 0 ];then
        echo "$i is installed"            
    else            
        yum -y install $i &>/dev/null                                                           
        action "$i is installing" /usr/bin/true           
    fi                     
done

echo "-----------------#3. Add Docker image source-----------------"
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[ $? -eq 0 ] && action "Docker Image add is ..." /usr/bin/true || echo "Docker Image add is ..." /usr/bin/false;exit

echo "-----------------#4. Install Docker-----------------"
yum -y install docker-ce 
rpm -qa |grep docker-ce 
[ $? -eq 0 ] && action "Docker-ce is installed ..." /usr/bin/true || action "Docker-ce is install ..." /usr/bin/false;exit

echo "-----------------#5. Start Docker and set it to start automatically at boot-----------------"
systemctl enable --now docker
[ $? -eq 0 ] && action "Docker Start is ...;" /usr/bin/true || action "Docker start is ..." /usr/bin/false
docker_version=`docker -v |awk -F ',' '{print $1}'`

echo "-----------------#6. Set up Docker accelerator-----------------"
sudo mkdir -p /etc/docker
sudo cat >/etc/docker/daemon.json <<EOF
{
      "registry-mirrors": ["https://8mh75mhz.mirror.aliyuncs.com"]
  }
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

echo "-----------------#7. Check whether Docker is installed successfully-----------------"
cat << EOF
+-------------------------------------------------+
| $docker_version Installation Completed|
| Please use the relevant services! |
+-------------------------------------------------+
EOF

echo "-----------------#8. Migrate Docker root directory-----------------"
systemctl stop docker
mv /var/lib/docker/ /data/
sed -i 's#ExecStart=/usr/bin/dockerd#ExecStart=/usr/bin/dockerd --graph=/data/docker#g' /usr/lib/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker.service

echo "-----------------#9. Verify that the Docker root directory is effective-----------------"
docker info |grep "Docker Root Dir"

sleep 5

echo ""-----------------Your little cutie has completed all Docker deployments-----------------"
#2. Add execution permissions to the script [root@ip-10-0-12-212 ~]# chmod +x Ins_Docker.sh 

#3. Execute the script [root@ip-10-0-12-212 ~]# sh Ins_Docker.sh

2. Pull the Jenkins image file

[root@ip-10-0-12-212 ~]# docker pull jenkins/jenkins

3. Create a mount directory and authorize

[root@ip-10-0-12-212 ~]# mkdir -p /data/jenkins_mount
[root@ip-10-0-12-212 ~]# chmod 777 /data/jenkins_mount

4. Create and start the Jenkins container

[root@ip-10-0-12-212 ~]# docker run -d -p 10240:8080 -p 10241:50000 -v /data/jenkins_mount:/var/jenkins_home -v /etc/localtime:/etc/localtime --name Datalake_Jenkins jenkins/jenkins
e0a9964d61fd5eb9f1c0eae0f2f18bdbfcd03ff0d5c2cc0d0beae31c134afa75

5. Check whether Jenkins is started successfully

[root@ip-10-0-12-212 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e0a9964d61fd jenkins/jenkins "/sbin/tini -- /usr/…" 13 seconds ago Up 12 seconds 0.0.0.0:10240->8080/tcp, :::10240->8080/tcp, 0.0.0.0:10241->50000/tcp, :::10241->50000/tcp Datalake_Jenkin

6. View Docker container logs

[root@ip-10-0-12-212 ~]# docker logs Datalake_Jenkins
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-18 02:00:12.630+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @1247ms to org.eclipse.jetty.util.log.JavaUtilLog
2021-10-18 02:00:12.772+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2021-10-18 02:00:14.184+0000 [id=1] WARNING oejshandler.ContextHandler#setContextPath: Empty contextPath
2021-10-18 02:00:14.319+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.43.v20210629; built: 2021-06-30T11:07:22.254Z; git: 526006ecfa3af7f1a27ef3a288e2bef7ea9dd7e8; jvm 11.0.12+7
2021-10-18 02:00:14.887+0000 [id=1] INFO oejwStandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2021-10-18 02:00:14.969+0000 [id=1] INFO oejssDefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2021-10-18 02:00:14.969+0000 [id=1] INFO oejssDefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2021-10-18 02:00:14.973+0000 [id=1] INFO oejserver.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
2021-10-18 02:00:15.909+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-18 02:00:16.516+0000 [id=1] INFO oejshandler.ContextHandler#doStart: Started w.@316a598d{Jenkins v2.316,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2021-10-18 02:00:16.586+0000 [id=1] INFO oejserver.AbstractConnector#doStart: Started ServerConnector@505a9d7c{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}

7. Access Jenkins

Visit the Jenkins page, http://52.82.80.128:10240

8. Install Jenkins

[root@ip-10-0-12-212 ~]# cd /data/jenkins_mount/
[root@ip-10-0-12-212 jenkins_mount]# cat secrets/initialAdminPassword 
67925445271c4fe593ba83eede0f9c75 

#2. Choose to install the recommended plugin

#3. Fill in the corresponding management user information, click Save and Complete.

#4. Configure the URL of Jenkins here.

#5. Jenkins is now installed. Click Start using Jenkins.

#6. You have entered the Jenkins page. The installed version number is displayed in the lower right corner. Now Jenkins is installed.

This is the end of this article about installing Jenkins with Docker-2.249.3-1.1. For more information about installing Jenkins with Docker, 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:
  • Practical notes on installing Jenkins with docker-compose
  • A detailed tutorial on how to install Jenkins on Docker for beginners
  • How to install Jenkins using Docker
  • Detailed tutorial on installing the jenkins container in a docker environment
  • Install Jenkins with Docker and solve the problem of initial plugin installation failure
  • Sample code for installing Jenkins using Docker
  • Docker deployment and installation steps for Jenkins

<<:  Sharing of web color contrast and harmony techniques

>>:  What is flex and a detailed tutorial on flex layout syntax

Recommend

Detailed explanation of the Sidecar mode in Docker Compose

Table of contents What is Docker Compose Requirem...

How to position the header at the top using CSS sticky layout

Application scenarios: One of the new requirement...

MySQL aggregate function sorting

Table of contents MySQL result sorting - Aggregat...

MySQL log settings and viewing methods

MySQL has the following logs: Error log: -log-err...

Basic reference types of JavaScript advanced programming

Table of contents 1. Date 2. RegExp 3. Original p...

Docker container time zone adjustment operation

How to check if the Docker container time zone is...

Mysql optimization tool (recommended)

Preface While browsing GitHub today, I found this...

Install nodejs and yarn and configure Taobao source process record

Table of contents 1. Download nodejs 2. Double-cl...

How to express relative paths in Linux

For example, if your current path is /var/log and...

Detailed explanation of docker's high availability configuration

Docker Compose Docker Compose divides the managed...

Should I abandon JQuery?

Table of contents Preface What to use if not jQue...

Use neat HTML markup to build your pages

The Internet is an organism that is constantly ev...