作者:穿越时空lily | 来源:互联网 | 2022-11-07 15:10
先前有一个问题(Docker Unknown标志--mount)面临着相同的错误,该错误是由于运行了最新版本的Docker所致。我正在运行最新版本的Docker。
我有以下内容Dockerfile
:
FROM continuumio/miniconda3
RUN --mount=type=ssh pip install git+ssh://git@github.com/myrepo/myproject.git@develop
RUN conda install numpy
...
根据文档,我应该能够简单地运行docker build --ssh default .
。但是,我收到以下错误:
Sending build context to Docker daemon 2.048kB
Error response from daemon: Dockerfile parse error line 3: Unknown flag: mount
输出docker version
:
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:39 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:13:06 2019
OS/Arch: linux/amd64
Experimental: true
我想构建一个Docker映像而不暴露我的私有SSH凭据,这似乎是受支持的方法。是否有人对导致问题的原因有任何想法?
1> Thomasleveil..:
tl; dr
Docker文件
# syntax=docker/dockerfile:experimental
FROM continuumio/miniconda3
RUN --mount=type=ssh pip install git+ssh://git@github.com/myrepo/myproject.git@develop
RUN conda install numpy
...
然后使用以下命令构建您的docker映像:
# syntax=docker/dockerfile:experimental
FROM continuumio/miniconda3
RUN --mount=type=ssh pip install git+ssh://git@github.com/myrepo/myproject.git@develop
RUN conda install numpy
...
有了这个,你就可以使用--mount
选项为RUN
您Dockerfile指令。
长答案
由于文档中找到这里,ssh的转发建筑搬运工图像时使用的时候才启用BuildKit后端:
外部实施功能
仅当使用BuildKit
后端时,此功能才可用
。
Docker build supports experimental features like cache mounts, build
secrets and ssh forwarding that are enabled by using an external
implementation of the builder with a syntax directive. To learn about
these features, refer to the documentation in BuildKit
repository.
For this you need Docker 18.09 (or later) and you also need to run the docker build
command with the DOCKER_BUILDKIT=1
environment variable and start your Docker file with the following magic comment: # syntax=docker/dockerfile:experimental
.
事实证明,我必须在Dockerfile中放置以下标头:`#语法= docker / dockerfile:1.0.0-experimental`。现在,我在主机密钥验证上遇到了失败。取得进展!
感谢您的回复。我尝试了这个,并得到了一个新错误:`未能创建LLB定义:Dockerfile解析错误行3:未知标志:mount`。