在码头工人内部运行码头工作是否可行? [英] Is it ok to run docker from inside docker?

查看:167
本文介绍了在码头工人内部运行码头工作是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个Docker容器里运行Jenkins。我想知道Jenkins集装箱是否也可以是Docker主机?我在想的是为Jenkins内部的每个集成测试版本(启动数据库,消息代理等)启动一个新的Docker容器。因此,在集成测试完成后,应关闭容器。有没有理由避免以这种方式从另一个docker容器运行docker容器?

解决方案

之前我回答了一个类似的问题如何在Docker内运行Docker容器


在docker内运行docker是绝对可能的。主要的是你运行外部容器与额外权限(以 - privileged = true 开头),然后在该容器中安装docker。 / p>

查看此博文以获取更多信息: Docker-in-Docker



一个潜在的用例在此条目。博客介绍了如何在Jenkins码头容器内部构建Docker容器。



然而,Docker Docker内部并不是解决这类问题的推荐方法。相反,推荐的方法是创建兄弟容器作为在这篇文章中描述


所以,在Docker内运行Docker被许多人认为是这种类型的问题的一个很好的解决方案。现在,趋势是使用兄弟容器。有关详细信息,请参阅此页上的@predmijat的答案


I'm running Jenkins inside a Docker container. I wonder if it's ok for the Jenkins container to also be a Docker host? What I'm thinking about is to start a new docker container for each integration test build from inside Jenkins (to start databases, message brokers etc). The containers should thus be shutdown after the integration tests are completed. Is there a reason to avoid running docker containers from inside another docker container in this way?

解决方案

I answered a similar question before on how to run a Docker container inside Docker.

To run docker inside docker is definitely possible. The main thing is that you run the outer container with extra privileges (starting with --privileged=true) and then install docker in that container.

Check this blog post for more info: Docker-in-Docker.

One potential use case for this is described in this entry. The blog describes how to build docker containers within a Jenkins docker container.

However, Docker inside Docker it is not the recommended approach to solve this type of problems. Instead, the recommended approach is to create "sibling" containers as described in this post

So, running Docker inside Docker was by many considered as a good type of solution for this type of problems. Now, the trend is to use "sibling" containers instead. See the answer by @predmijat on this page for more info.

这篇关于在码头工人内部运行码头工作是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆