Docker in Docker(dind) Jenkins实践
Docker in Docker(dind) image用于jenkins做build,在image里面装好第三方,然后jenkins有docker插件如Yet Another Docker Plugin(https://wiki.jenkins.io/display/JENKINS/Yet+Another+Docker+Plugin),管理这些image, 可以在一台机器上起多个docker i
·
Docker in Docker(dind)
Docker in Docker(dind) image可以用于Jenkins做build,在image里面装好第三方,然后Jenkins有docker插件如Yet Another Docker Plugin(https://wiki.jenkins.io/display/JENKINS/Yet+Another+Docker+Plugin), 管理这些image, 可以在一台机器上起多个docker image,每个image里面安装不同的第三方,形成不同的build环境,然后可以将待编译的代码SCP或GIT过去,用指定账号SSH来进行编译,达到一个机器多种编译环境的效果,提高了效率。
我基于最新的centos7和amazonlinux的做的dind, 内置jenkinsbuild账号, 可以用于Jenkins build。Docker Hub
从docker hub上search:docker search gammagao
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gammagao/dind amazonlinux Docker in Docker(dind) image(Ama… 1 [OK]
gammagao/centos7-dind Centos7 Docker in Docker(dind), can be used … 1 [OK]
从docker hub上pull:
docker pull gammagao/dind
docker pull gammagao/centos7-dind
gammagao/dind内建了golang的编译环境以及常用包。
RUN
RUN:
docker run -d -p 22 -v /var/run/docker.sock:/var/run/docker.sock gammagao/dindCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME
e580b223aa71 gammagao/dind "entrypoint.sh /usr/…" 4 seconds ago Up 3 seconds 0.0.0.0:32798->22/tcp adoring_goldwasser
SCP:
scp -P 32798 -r <buildsourcecode> jenkinsbuild@localhost:/home/jenkinsbuild/ci-jenkins/
SSH:
ssh -p 32798 jenkinsbuild@localhost
LINK
Docker hub地址:https://hub.docker.com/r/gammagao/dind/
https://hub.docker.com/r/gammagao/centos7-dind/
Github Dockerfile地址:
https://github.com/GammaGao/docker-in-docker
https://github.com/GammaGao/centos7-dind
更多推荐
已为社区贡献1条内容
所有评论(0)