
我正在尝试在OpenShift中设置一个运行Jenkins的容器,该容器本身可以运行docker来利用声明式管道,在该管道中构建在其自己的docker容器中运行.这基本上使得有必要在此容器中安装和运行docker.
我已经研究了很长时间了.在线检查了数十个帖子和主题,但我无法完成.基本上我到目前为止
>我可以在容器中安装docker(来自baseimage openshift / jenkins-2-centos7:latest)
>我无法让docker运行,因为这利用了systemctl
现在,我了解到systemctl在docker容器中不起作用,或者至少非常不建议这样做,因为它会干扰系统中的PID 1.不带
systemctl start docker
这将使我离开docker beeing无法连接到守护程序(按预期方式)和错误消息
Can’t connect to docker daemon. Is ‘docker -d’ running on this host?
所以我尝试自己使用设置后台程序
我的Dockerfile中的关注
RUN usermod -aG docker $(whoami) RUN dockerd -H unix:///var/run/docker.sock告诉我无法挂载cgroup,这也将不起作用.经过更多研究后,我发现可以使用以下命令中的cgroupfs-mount脚本来处理
https://github.com/tianon/cgroupfs-mount/tree/master
但是在这里我也没有运气让我遇到以下错误
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.4.21: can’t initialize iptables table `nat’: Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.现在几个小时后我就没主意了.有谁知道如何使docker在OpenShift内工作?真的很棒
文章:
The primary purpose of Docker-in-Docker was to help with the development of Docker itself. Many people use it to run CI (e.g. with Jenkins), which seems fine at first, but they run into many “interesting” problems that can be avoided by bind-mounting the Docker socket into your Jenkins container instead.
DinD回购:
This work is now obsolete, thanks to the combined efforts of some amazing people like @jfrazelle and @tianon, who also are black belts in the art of putting IKEA furniture together.
If you want to run Docker-in-Docker today, all you need to do is:
docker run --privileged -d docker:dind
所以here是一篇使用另一种方法在Docker容器内使用Jenkins构建Docker容器的文章:
docker run -p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
--name jenkins \
jenkins/jenkins:lts
因此,您可能要使此解决方案之一适合您的OpenShift方案.希望它能解决您的问题.
转载注明原文:在Openshift中运行的Docker容器中安装和运行Docker - 乐贴网