在未安装Docker的情况下构建Docker映像 [英] Build docker image without docker installed

查看:118
本文介绍了在未安装Docker的情况下构建Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不安装docker的情况下构建映像.在我的项目的Maven构建中,我想生成docker映像,但是我不想强迫其他人在他们的计算机上安装docker.

Is it somehow possible to build images without having docker installed. On maven build of my project I'd like to produce docker image, but I don't want to force others to install docker on their machines.

我可以想到一些安装了docker的虚拟盒子映像,但这是一种繁重的解决方案.是否有某种方法可以仅使用某些Maven插件,一些Go代码或已为此目的准备好的虚拟盒映像来构建映像?

I can think of some virtual box image with docker installed, but it is kind of heavy solution. Is there some way to build the image with some maven plugin only, some Go code or already prepared virtual box image for exactly this purpose?

归根结底是质疑如何使用docker而不强迫用户安装任何东西.只是用于构建,甚至用于运行Docker映像.

It boils down to question how to use docker without forcing users to install anything. Either just for build or even for running docker images.

更新

有一些,不是最新的,用于虚拟机配置的Maven插件带有流浪汉的使用vbox .我发现了有关建立在巴塞尔上没有docker的docker镜像 到目前为止,我看到了两个选择,要么我可以以某种方式仅构建映像,要么运行带有docker daemon的虚拟机(不仅可以用于构建,甚至可以用于集成测试)

There are some, not really up to date, maven plugins for virtual machine provisioning with vagrant or with vbox. I have found article about building docker images without docker on basel So far I see two options either I can somehow build the images only or run some VM with docker daemon inside(which can be used not only for builds, but even for integration tests)

推荐答案

我们可以在不安装Docker的情况下创建Docker映像.

We can create Docker image without Docker being installed.

Jib Maven和Gradle插件

Google有一个名为Jib的开源工具,它相对较新,但是 有很多原因,这很有趣.可能是最有趣的 问题是您不需要docker来运行它-它使用以下命令构建映像 与从docker build获得的标准输出相同,但未使用 docker除非您要求-否则它可以在docker是 未安装(在构建服务器中并不罕见).您也不需要 Dockerfile(无论如何都会被忽略),或者您的pom.xml中的任何内容 获取在Maven中构建的映像(Gradle将要求您至少安装 build.gradle中的插件).

Google has an open source tool called Jib that is relatively new, but quite interesting for a number of reasons. Probably the most interesting thing is that you don’t need docker to run it - it builds the image using the same standard output as you get from docker build but doesn’t use docker unless you ask it to - so it works in environments where docker is not installed (not uncommon in build servers). You also don’t need a Dockerfile (it would be ignored anyway), or anything in your pom.xml to get an image built in Maven (Gradle would require you to at least install the plugin in build.gradle).

Jib的另一个有趣特征是它被认为是 层,并以与多层结构稍有不同的方式对其进行优化 上面创建的Dockerfile层.就像在胖罐子里一样,Jib分开了 来自依赖项的本地应用程序资源,但它又走了一步 并且还将快照依赖项放在一个单独的层中,因为它们是 更有可能改变.有一些配置选项可用于自定义 进一步布局.

Another interesting feature of Jib is that it is opinionated about layers, and it optimizes them in a slightly different way than the multi- layer Dockerfile created above. Just like in the fat jar, Jib separates local application resources from dependencies, but it goes a step further and also puts snapshot dependencies into a separate layer, since they are more likely to change. There are configuration options for customizing the layout further.

请参阅以下链接 https: //cloud.google.com/blog/products/gcp/introducing-jib-build-java-docker-images-better

例如,对于Spring Boot,请参考 https://spring.io/blog/2018/11/08/spring-boot-in-a-container

For example with Spring Boot refer https://spring.io/blog/2018/11/08/spring-boot-in-a-container

这篇关于在未安装Docker的情况下构建Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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