来自守护程序的错误响应:Dockerfile分析错误未知标志:安装 [英] Error response from daemon: Dockerfile parse error Unknown flag: mount

查看:188
本文介绍了来自守护程序的错误响应:Dockerfile分析错误未知标志:安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个先前的问题( Docker Unknown标志--mount )面临相同的错误那是因为运行了一个过时的Docker版本。我有一个最新版本的Docker。

There is a previous question (Docker Unknown flag --mount) facing the same error that was due to having an out-of-date version of Docker running. I have an up-to-date version of Docker running.

我有以下 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。。但是,我收到以下错误:

According to the documentation, I should be able to simply run docker build --ssh default .. However, I receive the following error:

Sending build context to Docker daemon  2.048kB
Error response from daemon: Dockerfile parse error line 3: Unknown flag: mount

docker版本的输出

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镜像而不暴露m专用SSH凭据,这似乎是受支持的方法。是否有人对导致此问题的原因有任何想法?

I would like to build a Docker image without exposing my private SSH credentials, and this seemed to be the supported method. Anyone have thoughts on what's causing the issue?

推荐答案

tl; dr



Dockerfile

# 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映像:

Then build your docker image with:

DOCKER_BUILDKIT=1 docker build --ssh default -t my_image .

有了这个,您就可以使用 -mount 选项在您的Dockerfile中使用 RUN 指令。

With this, you will be able to use the --mount option for the RUN directive in your Dockerfile.

如文档此处 ssh转发,仅当使用 BuildKit 后端:

As found in the documentation here, ssh forwarding when building docker image is enabled only when using the BuildKit backend:


外部实现功能



此功能仅在使用
BuildKit
后端。

External implementation features

This feature is only available when using the BuildKit backend.

Docker build s支持实验性功能,例如缓存安装,构建
机密和ssh转发,这些功能通过使用带有语法指令的构建器的外部
实现来启用。要了解
这些功能,请参阅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.

为此,您需要 Docker 18.09 (或更高版本),还需要使用 DOCKER_BUILDKIT = 1 运行 docker build 命令>环境变量,并使用以下魔术注释启动Docker文件:#语法= docker / dockerfile:实验

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分析错误未知标志:安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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