Docker映像-类型。苗条vs苗条伸展vs伸展vs高山 [英] Docker images - types. Slim vs slim-stretch vs stretch vs alpine
问题描述
我正在寻找一个docker映像来构建一个Java应用程序,并查看可用的OpenJDK映像的变体。
我在这里 https://github.com/docker -library / openjdk / tree / master / 8 / jdk 并查看高山,薄型和窗户。
这些变量和每个变量有什么区别?
每个Docker库文档(引用和链接)下面是一个摘要:
-
openjdk:< version>
实际图像。
-
openjdk:< version> -buster
,openjdk:< version> -stretch
和openjdk:< version> -jessie
破坏者
, jessie
或 stretch
是 Debian 并指示图像基于哪个版本。
-
openjdk:< version> -alpine
类似地,该图像基于 Alpine Linux ,因此是非常小的基础映像。如果您需要图像尺寸尽可能小,建议您这样做。需要说明的是,它使用了一些不寻常的库,但对于大多数软件来说应该不是问题。如有疑问,请查看下面的官方文档。
-
openjdk:< version>
(从12开始),openjdk:< version> -oracle
和openjdk:< version> -oraclelinux7
从 openjdk:12
开始以及 -oracle
和 -oraclelinux7
变体均基于官方 Oracle Linux 7映像。
默认映像中的OpenJDK二进制文件以及 -oracle
和 -oraclelinux7
变体由Oracle,并且来自 OpenJDK社区。
-
openjdk:< version> -slim
此图像仅包含运行Java所需的最少软件包(例如,缺少许多与UI相关的Java库)。除非您在仅部署 openjdk
映像且有空间限制的环境中工作,否则建议在该映像上使用默认映像。
-
openjdk:< version> -windowsservercore
此图片基于 Windows Server Core( microsoft / windowsservercore
)。
图像变体
openjdk
图像有许多种风格,每一种都是针对
特定用例。
openjdk:< version>
这是实际图像。如果您不确定
的需求是什么,则可能要使用这一点。它旨在用作
的一次性容器(安装源代码并启动
容器以启动您的应用),以及用作构建其他
图像的基础。
其中一些标签的名称可能像jessie或Stretch。
这些是
发行版的套件代码名称 Debian 并指出哪个
释放图像所基于的。
openjdk:
-alpine
此图片基于流行的 Alpine Linux
项目,可在alpine
官方
图片 。高山Linux的
比大多数分发基础映像(〜5MB)要小得多,因此通常可以使
的映像更苗条。
此变体当需要使最终图像尺寸尽可能小
时,强烈建议使用。需要注意的主要警告是,它确实
使用 musl libc 代替了 glibc和
朋友,因此某些
软件可能会遇到问题,具体取决于其libc的深度
的要求。但是,大多数软件对此都没有问题,
,因此通常使用此变体是非常安全的选择。有关
的更多讨论,请参见此Hacker News
评论线程。
为最小化图像大小,使用其他相关工具$ b $并不常见b(例如
git
或bash
)包含在基于高山的图像中。以
这个映像为基础,在自己的Dockerfile
中添加所需的内容(请参见alpine
图片
描述,以示例如何在不熟悉的情况下
安装软件包。)
openjdk:< version> -windowsservercore
此图片基于 Windows Server Core
(microsoft / windowsservercore
)。
因此,它仅在该图像可以使用的地方工作,例如
Windows 10专业版/企业版(周年纪念版)或Windows
Server 2016。
有关如何在Windows上运行Docker的信息,请参阅
Microsoft提供的相关快速入门指南:
openjdk:< version> -slim
此映像安装了OpenJDK的
-headless
软件包,因此
缺少许多与UI相关的Java库和一些常见的软件包
包含在默认标记中。它仅包含运行Java所需的最少软件包
。除非您在
onlyopenjdk
映像将被部署且空间有限的环境中工作,否则我们强烈建议您使用
存储库的默认图像。
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
andopenjdk:<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
andopenjdk:<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
orbash
) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see thealpine
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 theopenjdk
image will be deployed and you have space constraints, we highly recommend using the default image of this repository.
这篇关于Docker映像-类型。苗条vs苗条伸展vs伸展vs高山的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!