問題描述
我正在尋找一個 docker 映像來構(gòu)建一個 java 應(yīng)用程序并查看可用的 OpenJDK 映像的變體.我在看這里 https://github.com/docker-library/openjdk/tree/master/8/jdk 并查看 alpine、slim 和 windows.這些之間有什么區(qū)別以及每個變體給出什么?
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?
推薦答案
每個 docker 庫文檔(下面的引用和鏈接),這里是一個摘要:
Per docker library docs (quote and links below), here's a summary:
openjdk:<版本>
事實上的形象.如果不確定,請使用它.
The defacto image. Use it if unsure.
openjdk:
、-buster openjdk:
和-stretch openjdk:
-jessie代碼>
buster
、jessie
或 stretch
是 Debian 并指明映像基于哪個發(fā)行版.
buster
, jessie
or stretch
are the suite code names for releases of Debian and indicate which release the image is based on.
openjdk:
-alpine
同樣,此映像基于 Alpine Linux,因此是一個非常小的基礎(chǔ)映像.如果您需要圖像尺寸盡可能小,建議使用.需要注意的是它使用了一些不尋常的庫,但對于大多數(shù)軟件來說應(yīng)該不是問題.如有疑問,請查看以下官方文檔.
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:
(從 12 開始),openjdk:
和-oracle openjdk:
;-oraclelinux7
openjdk:<version>
(from 12 onwards),openjdk:<version>-oracle
andopenjdk:<version>-oraclelinux7
從 openjdk:12
開始的默認鏡像以及 -oracle
和 -oraclelinux7
變體都是基于官方的 Oracle Linux 7 映像.默認映像中的 OpenJDK 二進制文件以及 -oracle
和 -oraclelinux7
變體由 Oracle 構(gòu)建,并來自 OpenJDK 社區(qū).
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:
-slim
此圖像僅包含運行 Java 所需的最少包(例如,缺少許多與 UI 相關(guān)的 Java 庫).除非您在僅 openjdk
映像將被部署并且您有空間限制的環(huán)境中工作,否則建議使用默認映像而不是此映像.
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:
-windowsservercore
此映像基于 Windows Server Core (microsoft/windowsservercore
).
This image is based on Windows Server Core (microsoft/windowsservercore
).
完整文檔(此處顯示的版本,這里是最新版本):
openjdk
圖像有多種風(fēng)格,每一種都是為具體用例.
Image Variants
The
openjdk
images come in many flavors, each designed for a specific use case.
這是事實上的圖像.如果您不確定自己的需求是,你可能想用這個.它被設(shè)計為同時使用作為一個扔掉的容器(安裝你的源代碼并啟動容器來啟動您的應(yīng)用程序),以及構(gòu)建其他應(yīng)用程序的基礎(chǔ)圖像關(guān)閉.
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.
其中一些標(biāo)簽可能包含像 jessie 或拉伸這樣的名稱.這些是版本的套件代號Debian 并指出哪個發(fā)布圖像是基于.
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.
此圖像基于流行的 Alpine Linux項目,在 alpine
官方提供圖片.Alpine Linux 要小得多比大多數(shù)分發(fā)基礎(chǔ)圖像(~5MB),因此導(dǎo)致很多總體而言,圖像更窄.
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.
當(dāng)最終圖像大小為盡可能小.需要注意的主要警告是它確實使用 musl libc 而不是 glibc 和朋友,那么肯定軟件可能會遇到問題,具體取決于其 libc 的深度要求.但是,大多數(shù)軟件都沒有這個問題,所以這個變體通常是一個非常安全的選擇.查看這個黑客新聞評論線程更多討論可能出現(xiàn)的問題和一些贊成/反對使用基于 Alpine 的圖像的比較.
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.
為了最小化圖像大小,額外的相關(guān)工具并不常見(例如 git
或 bash
)要包含在基于 Alpine 的圖像中.使用以此圖像為基礎(chǔ),在自己的 Dockerfile 中添加你需要的東西(參見 alpine
圖像描述 舉例說明如何如果您不熟悉,請安裝軟件包.
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).
此圖像基于 Windows Server Core(microsoft/windowsservercore
).因此,它僅適用于該圖像的位置,例如Windows 10 專業(yè)版/企業(yè)版(周年紀(jì)念版)或 Windows服務(wù)器 2016.
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.
有關(guān)如何讓 Docker 在 Windows 上運行的信息,請參閱微軟提供的相關(guān)快速入門"指南:
For information about how to get Docker running on Windows, please see the relevant "Quick Start" guide provided by Microsoft:
- Windows Server 快速入門
- Windows 10 快速入門
這個鏡像安裝了 OpenJDK 的 -headless
包,所以是缺少許多與 UI 相關(guān)的 Java 庫和一些常用包包含在默認標(biāo)簽中.它只包含最小的包需要運行 Java.除非你在一個環(huán)境中工作只有 openjdk
鏡像會被部署并且你有空間限制,我們強烈推薦使用這個默認鏡像存儲庫.
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.
這篇關(guān)于Docker 圖像 - 類型.修身vs修身彈力vs彈力vs高山的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!