1. 程式人生 > 實用技巧 >【Docker】解析器指令之 syntax

【Docker】解析器指令之 syntax

參考教程:https://docs.docker.com/engine/reference/builder/

環境

  1. virtual box 6.1
  2. centos 7.8
  3. docker 19.03

syntax

# syntax=[remote image reference]

For example:
例如:

# syntax=docker/dockerfile
# syntax=docker/dockerfile:1.0
# syntax=docker.io/docker/dockerfile:1
# syntax=docker/dockerfile:1.0.0-experimental
# syntax=example.com/user/repo:tag@sha256:abcdef...

This feature is only enabled if the BuildKit backend is used.

僅在使用 BuildKit 後端時啟用此功能。

BuildKit 是實驗性功能,這裡不講。

The syntax directive defines the location of the Dockerfile builder that is used for building the current Dockerfile. The BuildKit backend allows to seamlessly use external implementations of builders that are distributed as Docker images and execute inside a container sandbox environment.

語法指令定義用於構建當前 Dockerfile 的 Dockerfile 構建器的位置。BuildKit 後端允許無縫使用構建器的外部實現,這些構建器以 Docker 映象的形式分發並在容器沙箱環境中執行。

Custom Dockerfile implementation allows you to:

自定義Dockerfile實現使您能夠:

  • Automatically get bugfixes without updating the daemon

  • Make sure all users are using the same implementation to build your Dockerfile

  • Use the latest features without updating the daemon

  • Try out new experimental or third-party features

  • 在不更新守護程式的情況下自動獲取錯誤修正

  • 確保所有使用者都使用相同的實現來構建您的 Dockerfile

  • 使用最新功能而不更新守護程式

  • 試用新的實驗性或第三方功能

Official releases

Docker distributes official versions of the images that can be used for building Dockerfiles under docker/dockerfile repository on Docker Hub. There are two channels where new images are released: stable and experimental.

Docker 分發了可用於在 Docker Hub 上的 docker/dockerfile 儲存庫下構建Dockerfile 的映象的正式版本。有兩個釋出新映象的渠道:穩定版和實驗版。

Stable channel follows semantic versioning. For example:

穩定的通道遵循語義版本控制。例如:

  • docker/dockerfile:1.0.0 - only allow immutable version 1.0.0

  • docker/dockerfile:1.0 - allow versions 1.0.*

  • docker/dockerfile:1 - allow versions 1.*.*

  • docker/dockerfile:latest - latest release on stable channel

  • docker/dockerfile:1.0.0 -僅允許不可變版本 1.0.0

  • docker/dockerfile:1.0 - 允許版本 1.0.*

  • docker/dockerfile:1 - 允許版本 1.*.*

  • docker/dockerfile:latest - 穩定版本的最新版本

The experimental channel uses incremental versioning with the major and minor component from the stable channel on the time of the release. For example:

在釋出時,實驗頻道使用穩定版本中主要和次要元件的增量版本控制。例如:

  • docker/dockerfile:1.0.1-experimental - only allow immutable version 1.0.1-experimental

  • docker/dockerfile:1.0-experimental - latest experimental releases after 1.0

  • docker/dockerfile:experimental - latest release on experimental channel

  • docker/dockerfile:1.0.1-experimental- 僅允許不可變版本1.0.1-experimental

  • docker/dockerfile:1.0-experimental - 1.0 之後的最新實驗版本

  • docker/dockerfile:experimental - 實驗版本上的最新版本

You should choose a channel that best fits your needs. If you only want bugfixes, you should use docker/dockerfile:1.0. If you want to benefit from experimental features, you should use the experimental channel. If you are using the experimental channel, newer releases may not be backwards compatible, so it is recommended to use an immutable full version variant.

您應該選擇最適合自己需求的渠道。如果只想修正錯誤,則應使用 docker/ dockerfile:1.0。如果您想從實驗功能中受益,則應使用實驗頻道。如果您正在使用實驗性頻道,則較新的版本可能無法向後相容,因此建議使用不可變的完整版本。

For master builds and nightly feature releases refer to the description in the source repository.

有關主版本和每晚釋出的功能,請參閱 原始碼倉庫 中的描述。

總結

介紹了 Dockerfile 指令解析器的 syntax 用法。