Error response from daemon: Dockerfile parse error Unknown flag: mount

后端 未结 3 1847
余生分开走
余生分开走 2020-12-29 01:27

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 versio

相关标签:
3条回答
  • 2020-12-29 02:03

    If you are using sudo for docker commands, you might need:

    sudo DOCKER_BUILDKIT=1 ...

    0 讨论(0)
  • 2020-12-29 02:09

    The error message that you are getting due to writing --mount inside the Dockerfile. You have to enable Docker BuildKit first in order to use this syntax.

    You can check all of the currently available build options through here

    0 讨论(0)
  • 2020-12-29 02:12

    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
    ...
    

    Note: the comment on the first line is required voodoo

    Then build your docker image with:

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

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


    Long answer

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

    External implementation features

    This feature is only available when using the BuildKit backend.

    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.

    0 讨论(0)
提交回复
热议问题