Docker 图像 - 类型.修身 vs 修身拉伸 vs 拉伸 vs 高山 [英] Docker images - types. Slim vs slim-stretch vs stretch vs alpine

查看:27
本文介绍了Docker 图像 - 类型.修身 vs 修身拉伸 vs 拉伸 vs 高山的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个 docker 镜像来构建一个 java 应用程序并查看可用的 OpenJDK 镜像的变体.我在这里查看 https://github.com/docker-library/openjdk/tree/master/8/jdk 并查看 alpine、slim 和 windows.这些之间有什么区别,每个变体给出了什么?

解决方案

每个 docker 库文档(下面的引用和链接),这里是一个摘要:

  • openjdk:

事实上的图像.如果不确定,请使用它.

  • openjdk:-busteropenjdk:-stretchopenjdk:-jessie

busterjessiestretchDebian 并指明映像基于哪个发行版.

  • openjdk:-alpine

同样,此映像基于 Alpine Linux,因此是一个非常小的基础映像.如果您需要图像尺寸尽可能小,建议使用.需要注意的是,它使用了一些不寻常的库,但对于大多数软件来说应该不是问题.如有疑问,请查看下面的官方文档.

  • openjdk:(从 12 开始)、openjdk:-oracleopenjdk:-oraclelinux7

openjdk:12 开始,默认镜像以及 -oracle-oraclelinux7 变体基于官方 Oracle Linux 7 映像.默认映像中的 OpenJDK 二进制文件以及 -oracle-oraclelinux7 变体由 Oracle 构建并源自 OpenJDK 社区.

  • openjdk:-slim

此图像仅包含运行 Java 所需的最少包(例如,缺少许多与 UI 相关的 Java 库).除非您在部署 openjdk 镜像的环境中工作并且您有空间限制,否则建议使用默认镜像而不是这个.

  • openjdk:-windowsservercore

此图像基于 Windows Server Core (microsoft/windowsservercore).


<小时>

完整文档(此处显示以下版本此处为最新版本):<块引用>

图像变体

openjdk 图像有多种风格,每一种都是为特定用例.

openjdk:

这是事实上的图像.如果您不确定自己的需求是,你可能想使用这个.它旨在同时使用作为一次性容器(安装源代码并启动容器来启动您的应用程序),以及构建其他应用程序的基础图片关闭.

其中一些标签可能有像 jessie 或 stretch 这样的名字.这些是发行版的套件代号Debian 并指出哪个发布图像基于.

openjdk:-alpine

此映像基于流行的 Alpine Linux项目,可在 alpine 官方获取图片.Alpine Linux 小得多比大多数分发基础图像(~5MB),因此导致很多一般来说,图像更薄.

当最终图像大小为希望尽可能小.要注意的主要警告是它确实使用 musl libc 而不是 glibc 和朋友,那么确定软件可能会遇到问题,具体取决于其 libc 的深度要求.但是,大多数软件都没有这个问题,所以这个变体通常是一个非常安全的选择.请参阅此黑客新闻评论线程更多讨论可能出现的问题以及一些赞成/反对意见使用基于 Alpine 的图像的比较.

为了最小化图像大小,其他相关工具并不常见(例如 gitbash)包含在基于 Alpine 的图像中.使用以这个镜像为基础,在自己的 Dockerfile 中添加你需要的东西(参见 alpine 图像说明有关如何操作的示例如果您不熟悉,请安装软件包).

openjdk:-windowsservercore

此图像基于 Windows Server Core(microsoft/windowsservercore).因此,它仅适用于该图像的位置,例如Windows 10 专业版/企业版(周年纪念版)或 Windows服务器 2016.

有关如何在 Windows 上运行 Docker 的信息,请参阅Microsoft 提供的相关快速入门"指南:

openjdk:-slim

这个镜像安装了 OpenJDK 的 -headless 包,所以是缺少许多与 UI 相关的 Java 库和一些常见的包包含在默认标签中.它只包含最小的包需要运行Java.除非你在这样的环境中工作将部署 openjdk 映像并且您有空间限制,我们强烈建议使用此默认映像存储库.

I am looking to pick up a docker image to build a java app and looking at the variants of the OpenJDK images available. I am looking here https://github.com/docker-library/openjdk/tree/master/8/jdk and see alpine, slim and windows. What are the differences between these and what does each variant give?

解决方案

Per docker library docs (quote and links below), here's a summary:

  • openjdk:<version>

The defacto image. Use it if unsure.

  • openjdk:<version>-buster, openjdk:<version>-stretch and openjdk:<version>-jessie

buster, jessie or stretch are the suite code names for releases of Debian and indicate which release the image is based on.

  • openjdk:<version>-alpine

Similarly, this image is based on the Alpine Linux, thus being a very small base image. It is recommended if you need an image size is as small as possible. The caveat is that it uses some unusual libs, but shouldn't be a problem for most software. In doubt, check the official docs below.

  • openjdk:<version> (from 12 onwards), openjdk:<version>-oracle and openjdk:<version>-oraclelinux7

Starting with openjdk:12 the default image as well as the -oracle and -oraclelinux7 variants are based on the official Oracle Linux 7 image. The OpenJDK binaries in the default image as well as the -oracle and -oraclelinux7 variants are built by Oracle and are sourced from the OpenJDK community.

  • openjdk:<version>-slim

This image only contains the minimal packages needed to run Java (and is missing many of the UI-related Java libraries, for instance). Unless you are working in an environment where only the openjdk image will be deployed and you have space constraints, the default image is recommended over this one.

  • openjdk:<version>-windowsservercore

This image is based on Windows Server Core (microsoft/windowsservercore).



Full docs (version shown below here, latest version here):

Image Variants

The openjdk images come in many flavors, each designed for a specific use case.

openjdk:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

Some of these tags may have names like jessie or stretch in them. These are the suite code names for releases of Debian and indicate which release the image is based on.

openjdk:<version>-alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

openjdk:<version>-windowsservercore

This image is based on Windows Server Core (microsoft/windowsservercore). As such, it only works in places which that image does, such as Windows 10 Professional/Enterprise (Anniversary Edition) or Windows Server 2016.

For information about how to get Docker running on Windows, please see the relevant "Quick Start" guide provided by Microsoft:

openjdk:<version>-slim

This image installs the -headless package of OpenJDK and so is missing many of the UI-related Java libraries and some common packages contained in the default tag. It only contains the minimal packages needed to run Java. Unless you are working in an environment where only the openjdk image will be deployed and you have space constraints, we highly recommend using the default image of this repository.

这篇关于Docker 图像 - 类型.修身 vs 修身拉伸 vs 拉伸 vs 高山的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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