$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
安装一些必要的系统工具:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
添加软件源信息:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存:
sudo yum makecache fast
安装 Docker-ce:
sudo yum -y install docker-ce
启动 Docker 后台服务
sudo systemctl start docker
多域名解析处理
docker run --name=nginx -p 80:80 -v /app/nginx/www:/usr/share/nginx/html -v /app/nginx/conf.d:/etc/nginx/conf.d -d nginx
vi /app/nginx/conf.d/gogs.conf
server {
listen 80;
server_name blog.chenhailong.online; # 把域名替换成你自己的
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://47.99.211.128:6666; # 这里设置你要代理的ip+端口
}
}
server {
listen 80;
server_name taro.chenhailong.online; # 把域名替换成你自己的
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://47.99.211.128:7071; # 这里设置你要代理的ip+端口
}
}
server {
listen 80;
server_name introduce.chenhailong.online; # 把域名替换成你自己的
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://47.99.211.128:7072; # 这里设置你要代理的ip+端口
}
}
server {
listen 80;
server_name jenkins.chenhailong.online; # 把域名替换成你自己的
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://47.99.211.128:8080; # 这里设置你要代理的ip+端口
}
}
docker exec -it nginx /etc/init.d/nginx reload
jenkins
# -u root --name myJenkins
docker run -u root --name myJenkins -d --restart=always -p 8080:8080 -v /root/jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v "$HOME"/jenkins:/home jenkinsci/blueocean
docker exec -it myJenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td>(本邮件由程序自动下发,请勿回复!)</td>
</tr>
<tr>
<td>
<h2><font color="#FF0000">构建结果 - ${BUILD_STATUS}</font></h2>
</td>
</tr>
<tr>
<td><br />
<b><font color="#0B610B">构建信息</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr><a href="${PROJECT_URL}">${PROJECT_URL}</a>
<td>
<ul>
<li>项目名称:${PROJECT_NAME}</li>
<li>GIT路径:<a href="${GIT_URL}">${GIT_URL}</a></li>
<li>构建编号:${BUILD_NUMBER}</li>
<li>触发原因:${CAUSE}</li>
<li>构建日志:<a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
</ul>
</td>
</tr>
<tr>
<td>
<b><font color="#0B610B">变更信息:</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr>
<td>
<ul>
<li>上次构建成功后变化 : ${CHANGES_SINCE_LAST_SUCCESS}</a></li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>上次构建不稳定后变化 : ${CHANGES_SINCE_LAST_UNSTABLE}</a></li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>历史变更记录 : <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a></li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>变更集:${JELLY_SCRIPT,template="html"}</a></li>
</ul>
</td>
</tr>
<!--
<tr>
<td>
<b><font color="#0B610B">Failed Test Results</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr>
<td>
<pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">$FAILED_TESTS</pre>
<br />
</td>
</tr>
<tr>
<td>
<b><font color="#0B610B">构建日志 (最后 100行):</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>-->
<!-- <tr>
<td>Test Logs (if test has ran): <a
href="${PROJECT_URL}ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip">${PROJECT_URL}/ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip</a>
<br />
<br />
</td>
</tr> -->
<!--
<tr>
<td>
<textarea cols="80" rows="30" readonly="readonly" style="font-family: Courier New">${BUILD_LOG, maxLines=100,escapeHtml=true}</textarea>
</td>
</tr>-->
<hr size="2" width="100%" align="center" />
</table>
</body>
</html>
// 无法运行docker 命令
docker run --name jenkins -u root -p 8080:8080 -p 50000:50000 -d -v /home/jenkins-home-docker:/var/jenkins_home jenkins/jenkins:lts
// 无法加载资源
docker run --name jenkins -u root -p 8180:8080 -p 50000:50000 -d -v /home/jenkins:/var/jenkins_home hub.c.163.com/library/jenkins
// 无法加载资源
docker run -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins
docker run --name jenkins -u root -p 8080:8080 -p 50000:50000 -d -v /home/jenkins_home:/var/jenkins_home jenkins
docker run --name blueocean -u root -p 8080:8080 -d -v /home/blueocean:/var/jenkins_home jenkinsci/blueocean
docker exec -ti jenkins whoami
wget http://mirrors.jenkins.io/war/latest/jenkins.war
docker cp jenkins.war 7415ceb55add:/usr/download
docker exec -it -u root 7415ceb55add bash
cp /usr/download/jenkins.war /usr/share/jenkins
docker cp jenkins.war 7415ceb55add:/usr/share/jenkins
// 什么鬼
[root@iZbp1hun1qsl59e2nzqyvcZ jen]# docker cp jenkins.war 7415ceb55add:/usr/download
[root@iZbp1hun1qsl59e2nzqyvcZ jen]# docker exec -it -u root 7415ceb55add bash
root@7415ceb55add:/# cp /usr/download/jenkins.war /usr/share/jenkins
cp: cannot stat '/usr/download/jenkins.war': Not a directory
root@7415ceb55add:/# cd usr
root@7415ceb55add:/usr# cd download
bash: cd: download: Not a directory
root@7415ceb55add:/usr# ls
bin download games include lib local sbin share src
root@7415ceb55add:/usr# cd download
bash: cd: download: Not a directory
root@7415ceb55add:/usr# ls
bin download games include lib local sbin share src
root@7415ceb55add:/usr# cd download
bash: cd: download: Not a directory
root@7415ceb55add:/usr#
docker run -itd --name jenkins -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /home/jenkins-home-docker:/var/jenkins_home --env JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxNewSize=256m" -u root -v /usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7 jenkins
113b957b3c0695a75f6ddd4d6d7cbe4a18372fa5