gocd是一个持续集成的工具,可视化效果非常好

运行gocd-server

1
2
3
4
5
docker run -d --name server 
-p8153:8153 -p8154:8154
-v /path/to/godata:/godata
-v /path/to/go:/home/go
gocd/gocd-server:v18.1.0

我们就可以通过http://go-server-ip:8153来访问gocd-server的web了

运行gocd-agent

1
2
3
4
5
6
7
docker run -d --name gocd 
-e AGENT_AUTO_REGISTER_KEY=53f57d90-c749-4758-b430-5af341117b0e
-e AGENT_AUTO_REGISTER_RESOURCES=diagnosis,bj
-e AGENT_AUTO_REGISTER_ENVIRONMENTS=bj
-e AGENT_AUTO_REGISTER_HOSTNAME=diagnosis_bj
-e GO_SERVER_URL=https://go-server-ip:8154/go
gocd/gocd-agent-centos-7:v18.1.0

其中AGENT_AUTO_REGISTER_KEY是在gocd-server的配置中。
执行完之后,就可以在web中看到添加的agent。

安装插件

1
2
cd /path/to/godata/plugins/external
wget https://github.com/gocd-contrib/script-executor-task/releases/download/0.3/script-executor-0.3.0.jar

DOOD

我们通常希望在agent中执行docker命令在宿主中建立镜像运行容器网上大家把这种技术称之为DOOD(docker outside of docker)。
docker命令只能在root权限下执行,但是gocd的脚本是在go用户下运行的所以会报错,解决办法就是想办法让脚本切换到root下运行脚本,具体办法如下:

创建su文件

su的文件内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
auth required pam_wheel.so use_uid
auth substack system-auth
auth include postlogin
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include syste 大专栏  在Docker中运行gocdm-auth
session include system-auth
session include postlogin
session optional pam_xauth.so

创建dockerfile制作dood-gocd镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
FROM gocd/gocd-agent-centos-7:v18.1.0
RUN yum install -y yum-utils
device-mapper-persistent-data
lvm2
RUN yum-config-manager
--add-repo
https://download.docker.com/linux/centos/docker-ce.repo
RUN yum install -y docker-ce
RUN yum -y install sudo
RUN echo 'go ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN gpasswd -a go wheel
COPY su /etc/pam.d/su
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone

这里的root方案就是在脚本中调用su root切换到root账户,并且取消输入密码。

1
2
3
4
5
6
7
8
9
10
docker build -t gocd-agent-dood .

docker run -d --name gocd 
-e AGENT_AUTO_REGISTER_KEY=53f57d90-c749-4758-b430-5af341117b0e
-e AGENT_AUTO_REGISTER_RESOURCES=diagnosis,bj
-e AGENT_AUTO_REGISTER_ENVIRONMENTS=bj
-e AGENT_AUTO_REGISTER_HOSTNAME=diagnosis_bj
-e GO_SERVER_URL=https://go-server-ip:8154/go
-v /var/run/docker.sock:/var/run/docker.sock
gocd-agent-dood

上面命令里的挂载就是把宿主机的docker.sock挂载到容器中,这样我们就能在gocd-agent-dood的容器中运行dock命名在宿主机上创建镜像运行容器了。

script如下:

1
2
3
4
su - root <<EOF
xxx
xxx
xxx

在Docker中运行gocd的更多相关文章

  1. 在docker中运行ASP.NET Core Web API应用程序

    本文是一篇指导快速演练的文章,将介绍在docker中运行一个ASP.NET Core Web API应用程序的基本步骤,在介绍的过程中,也会对docker的使用进行一些简单的描述.对于.NET Cor ...

  2. .NET Core Web 应用部署到 Docker 中运行

    环境介绍 : 虚拟机:VirtualBox 5.1.6 系 统:Ubuntu 16.04.1 LTS 系统准备完成后可以使用 sudo apt-get udpate 和 sudo apt-get up ...

  3. docker中运行ASP.NET Core Web API

    在docker中运行ASP.NET Core Web API应用程序 本文是一篇指导快速演练的文章,将介绍在docker中运行一个ASP.NET Core Web API应用程序的基本步骤,在介绍的过 ...

  4. 在Docker中运行torch版的neural style

    相关的代码都在Github上,请参见我的Github,https://github.com/lijingpeng/deep-learning-notes 敬请多多关注哈~~~ 在Docker中运行to ...

  5. ASP.NET Core 网站在Docker中运行

    Docker作为新一代的虚拟化方式,未来肯定会得到广泛的应用,传统虚拟机的部署方式要保证开发环境.测试环境.UAT环境.生产环境的依赖一致性,需要大量的运维人力,使用Docker我们可以实现一次部署, ...

  6. 在Docker中运行EOS(MAC版)

    在Docker中运行EOS(MAC版) 在Docker中也可以简单快速的构建EOS.IO.笔者在Mac平台下参考官方文档躺了一次河.记录如下: 安装依赖 Docker 版本 17.05或者更高 tes ...

  7. 在docker中运行jenkins实现代码自动发布到测试服务器

    在docker中运行jenkins 用的镜像是apline版:lts-alpine,并设置正确的时区. docker run --name jenkins_master -d \ -p 8081:80 ...

  8. 在Docker中运行纸壳CMS并配置使用MySql

    纸壳CMS是基于ASP.Net Core开发的可视化内容管理系统,可以跨平台部署,可以在容器中运行.接下来看看如何在docker中运行纸壳CMS. GitHub:https://github.com/ ...

  9. 在docker中运行elasticsearch时go程序无法连接到节点

    错误信息: panic: no active connection found: no Elasticsearch node available 在docker中运行es时,默认启动sniffing  ...

随机推荐

  1. [USACO09MAR]向右看齐Look Up(单调栈、在线处理)

    https://www.luogu.org/problem/P2947 题目描述 Farmer John's N (1 <= N <= 100,000) cows, convenientl ...

  2. 4.windows-oracle实战第四课 -表的查询

    所有语句均为安装oracle数据库后scott的默认表emp,dept等表 1.自己插入自己:insert into 表名 (字段)select *from 表名 2.去除重复行: select di ...

  3. 限制客户端同账号同IP多终端登录

    打开SoftEther VPN Server Manager工具,连接上节点 1.管理虚拟HUB--管理用户--双击用户--安全策略--最大多重登录数设置为1 2.管理虚拟HUB--虚拟HUB属性-- ...

  4. SecureCRT8.3

    https://blog.csdn.net/dff1993/article/details/81189610 这篇文章我试过,成功激活了SecureCRT8.3

  5. 吴裕雄--天生自然C语言开发:函数指针

    #include <stdio.h> int max(int x, int y) { return x > y ? x : y; } int main(void) { /* p 是函 ...

  6. 转:lightGBM的黑科技--plot函数

    本来想研究一下lightGBM的plotting相关的接口,发现网上已经有人做了,而且还挺不错的(lightGBM的黑科技--plot函数),就直接给转过来了 # -*- coding: utf-8 ...

  7. java 的CAS

    CAS:什么是 CAS 机制?cas目的是实现原子操作解释一下:"原子操作(atomic operation)是不需要synchronized",这是多线程编程的老生常谈了.所谓原 ...

  8. struts.xml中namespace的配置之浏览器兼容性

    还是做练习项目的时候发现一个问题: <span style="font-size:14px;"><package name="default" ...

  9. laravel如何输出最后一条执行的SQL

    \DB::connection()->enableQueryLog(); // 开启查询日志 \DB::table('xxx'); // 要查看的sql $queries = \DB::getQ ...

  10. json转换为go类文件,js脚本,nodejs执行

    js写的代码生成脚本,json生成对应的go type对象 作json转换用 js脚本无甚何依赖,可以直接运行 执行前,按需更改文件 示例 var topname="Data"; ...