1. Preparation
A server running CentOS ensures that there is enough disk space, memory resources, and a stable network connection. It is recommended to use CentOS 7 or higher. This article uses CentOS 7 as an example to explain it.
Have root permissions on the server because subsequent installation of software packages, configuring the environment and other operations require higher permissions.
2. Install Docker
1. Update the yum package index:
yum update -y
This step ensures that we can get the latest package information.
2. Install the necessary dependency packages:
yum install -y yum-utils device-mapper-persistent-data lvm2
These dependencies are required for Docker to function properly.
3. Add Docker official yum source:
yum-config-manager --add-repo /linux/centos/
4. Install Docker CE (Community Edition):
yum install -y docker-ce docker-ce-cli
The installation process may take some time depending on server performance and network conditions.
5. Start Docker service and set up power-on self-start:
systemctl start dockersystemctl enable docker
6. Verify that Docker is installed successfully and run:
docker --version
If version information is displayed, it means that Docker has been successfully installed on the CentOS server.
3. Configure Docker image acceleration
Since Docker's default image source is slow to access in China, we can configure domestic mirror acceleration services, such as using Alibaba Cloud mirror acceleration.
Log in to the Alibaba Cloud console, find the container mirroring service, and obtain the exclusive mirror acceleration address.
Create or edit the /etc/docker/ file:
{  "registry-mirrors": \["Your Alibaba Cloud Mirror Acceleration Address"]}
Restart the Docker service to make the configuration take effect:
systemctl restart docker
4. Install Jenkins
1. Download Jenkins' yum source:
wget -O /etc// /redhat-stable/
2. Import Jenkins' GPG key:
rpm --import /redhat-stable/
3. Install Jenkins:
yum install -y jenkins
4. Start the Jenkins service and set up the power-on self-start:
systemctl start jenkinssystemctl enable jenkins
Jenkins runs on port 8080 by default. At this time, enter the server IP address: 8080 in the browser to access the Jenkins initial page.
5. Configure Jenkins
1. When you first access Jenkins, you need to enter the initial password to unlock it.
The password is stored in the server's /var/lib/jenkins/secrets/initialAdminPassword file, and the command is:
cat /var/lib/jenkins/secrets/initialAdminPassword
Get the password and paste it into your browser.
2. Enter the plug-in installation page and you can choose to install the recommended plug-ins. These plug-ins cover common build, testing and other functions, making it convenient and quickly building the CI process.
Wait for the plug-in to be installed.
3. Create an administrator account, fill in username, password and other information, and complete the basic configuration of Jenkins.
6. Integration of Docker and Jenkins
Install the Docker plugin in Jenkins:
Log in to the Jenkins console, go to "System Management" -> "Plugin Management", search for "Docker" in the optional plug-in and install.
Configure Docker connection:
In "System Management" -> "System Settings", find the "Docker" section, fill in the URL of the Docker server (usually unix:///var/run/), and save after the test connection is successful.
So far, we have successfully deployed the Docker+Jenkins continuous integration environment on the CentOS server. Subsequently, creating project tasks in Jenkins, combined with the containerization advantages of Docker, can easily achieve continuous integration and rapid deployment of code, making the software development process more efficient and reliable. In the process of practice, continuously optimize the configuration according to the characteristics of the project and give full play to the power of this powerful combination.
This is the article about deploying Docker+Jenkins continuous integration environment in CentOS server. For more related content on Docker Jenkins continuous integration environment, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!