Sample code for installing Jenkins using Docker

Sample code for installing Jenkins using Docker

Two problems that are easy to encounter when installing docker containers

1.Port is already allocated (port has been assigned)

Solution: Change the port

2. that container to be able to reuse that name

Solution: View (delete) the previous container

docker ps -a | grep jenkins_im
docker rm jenkins_im

Start the Docker service

sudo systemctl start docker

vi /home/jenkins/docker-compose.yml, create docker-compose.yml

version: '3'
services:
 Jenkins: 
  container_name: 'jenkins'
  image: jenkins/jenkins:lts
  restart: always
  user: jenkins:994
  ports: 
  - "11005:8080"
  - "50000:50000"
  - "10051:10051"
  volumes:
  - /home/jenkins/data:/var/jenkins_home
  - /usr/bin/docker:/usr/bin/docker
  - /var/run/docker.sock:/var/run/docker.sock

If there is no such file before, you cannot save it after modification. Change vi to vim

Here are the installation steps

Go to github and copy the command

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

Open the terminal and connect to the remote test server using ssh

Paste the command above, modify the default port 8080, map it to another host port, and specify the container name. Press Enter. If everything goes well, a string of hash values ​​will be printed out.

docker run --name jenkins_im -itd -p 11005:8080 -p 50000:50000 jenkins/jenkins:lts // -itd: Add an interactive terminal and let this command run docker in the background

Execute the following command to check whether the container is running

docker ps | grep jenkins_im

Execute the following command to print the information in the container. You will see an administrator password. Save it for later use. Press ctrl+c to exit the log command.

docker logs -f jenkins_im

If the firewall is not turned off, let the firewall open the 11005 port set above

firewall-cmd --add-port=11005/tcp --permanent

Then reload the firewall

firewall-cmd --reload

At this time, you can access it by adding the IP and port number of the virtual machine in the browser. The next steps are:

  • Enter the administrator password you just saved
  • Select Install recommended plugins
  • If you see an offline reminder, it may be that the IP set previously cannot access Google's services. Some plug-ins need to access Google to download and install. The solution is to set up a proxy, or install it offline. You can configure the Tsinghua Accelerator Source Download Plug-in
  • Create an administrator account
  • The instance configuration will have a URL, which you will need to use when connecting to gitlab in the future. If you need to modify it, you can modify it in the system settings
  • After logging in, configure the URL of the update site in the advanced of manage plugins in system management. What URL is it? It is the link of update-center.json of Tsinghua open source mirror.
  • If you want to go to the official website to download relevant plug-ins, after downloading, click the upload plug-in here to install it.
  • Run the container next time
docker start <container name>

This is the end of this article about sample code for installing Jenkins with Docker. 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:
  • Detailed process of installing Jenkins-2.249.3-1.1 with Docker
  • 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
  • Docker deployment and installation steps for Jenkins

<<:  Tutorial diagram of installing mysql8.0.18 under linux (Centos7)

>>:  The difference and usage of datetime and timestamp in MySQL

Recommend

The whole process of installing gogs with pagoda panel and docker

Table of contents 1 Install Docker in Baota Softw...

Thoroughly understand JavaScript prototype and prototype chain

Table of contents Preface Laying the foundation p...

JavaScript lazy loading detailed explanation

Table of contents Lazy Loading CSS styles: HTML p...

TCP third handshake data transmission process diagram

The process packets with the SYN flag in the RFC7...

Very practical Tomcat startup script implementation method

Preface There is a scenario where, for the sake o...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

CSS3 animation – steps function explained

When I was looking at some CSS3 animation source ...

Detailed explanation of JavaScript function this pointing problem

Table of contents 1. The direction of this in the...

Perfect solution to Google Chrome autofill problem

In Google Chrome, after successful login, Google ...

CSS3 category menu effect

The CSS3 category menu effects are as follows: HT...

A brief discussion on CSS cascading mechanism

Why does CSS have a cascading mechanism? Because ...

Example of using docker compose to build a consul cluster environment

Basic concepts of consul Server mode and client m...

Let's talk in detail about the props attributes of components in Vue

Table of contents Question 1: How are props used ...

How to install php7 + nginx environment under centos6.6

This article describes how to install php7 + ngin...