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.
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" | bash2. Install Docker using the official script.
curl -fsSL "https://get.docker.com/" | bash -s -- --mirror AliyunLoad 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.ioEnable and start Docker service.
systemctl enable docker && systemctl start dockerInstall 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=true2. Install and start Nginx.
yum -y install nginx
nginx3. Add host resolution entry.
echo "127.0.0.1 www.google.com" >> /etc/hostsInstall 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.64. 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
