Operations 6 min read

Step‑by‑Step Guide to Install Docker, Nginx, and Jenkins on CentOS

This tutorial walks you through replacing yum sources, installing and configuring Docker with kernel tweaks and a mirror, adding the Nginx repository and setting up host resolution, then pulling and running a Jenkins container while addressing common plugin‑download issues.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step‑by‑Step Guide to Install Docker, Nginx, and Jenkins on CentOS

Install and configure Docker

1. Replace yum source if not already using a domestic mirror.

curl -fsSL "https://gitee.com/clay-wangzhi/shell/raw/master/repo_replace.sh" | bash

2. Install Docker using the official script.

curl -fsSL "https://get.docker.com/" | bash -s -- --mirror Aliyun

Load br_netfilter module. modprobe br_netfilter Set kernel parameters.

cat <<EOF > /etc/sysctl.d/docker.conf
# iptables should not process bridge traffic
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
# enable forwarding
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/docker.conf
⚠️ Use sysctl --system with caution; parameters in different files have priority, with /etc/sysctl.conf taking highest precedence.

Configure Docker image accelerator.

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

Enable and start Docker service.

systemctl enable docker && systemctl start docker

Install and configure Nginx

1. Add Nginx yum repository by creating /etc/yum.repos.d/nginx.repo with the following content:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

2. Install and start Nginx.

yum -y install nginx
nginx

3. Add host resolution entry.

echo "127.0.0.1 www.google.com" >> /etc/hosts

Install and configure Jenkins

⚠️ Before this step, Nginx must be installed. When Docker runs with --network=host , updating the host's /etc/hosts does not affect the container's hosts file (Docker 20.10.6).

1. Pull Jenkins image. docker pull jenkinsci/blueocean:1.24.6 2. Create data directory. mkdir -p /opt/jenkins-data 3. Run Jenkins container with host network and bind mount.

docker run -u root --rm -d -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai --mount type=bind,source=/opt/jenkins-data,target=/var/jenkins_home --network=host --name jenkins jenkinsci/blueocean:1.24.6

4. Follow on‑screen prompts to finish setup. If the Jenkins instance appears offline after entering the password, two workarounds are available:

Change the plugin update site URL to a domestic mirror (e.g., http://mirror.esuni.jp/jenkins/updates/update-center.json) via /pluginManager/advanced, then restart Jenkins.

Edit /var/lib/jenkins/updates/default.json and set connectionCheckUrl to an accessible address.

Both methods may not guarantee 100 % success; the first only changes the download source check, and the second may be overwritten by Jenkins.

Since connectionCheckUrl is only used to verify network reachability for plugins, a simple solution is to map www.google.com to the local machine and let Nginx respond.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockercontainerizationNginxCentOS
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.