Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
Error response from daemon: Dockerfile parse error Unknown flag: mount

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.

I have the following Dockerfile:

FROM continuumio/miniconda3

RUN --mount=type=ssh pip install git+ssh://git@github.com/myrepo/myproject.git@develop
RUN conda install numpy
...

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

Output of 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

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?

over 4 years ago · Santiago Trujillo
5 answers
Answer question

0

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

over 4 years ago · Santiago Trujillo Report

0

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.

Also you can edit /etc/docker/daemon.json and add :

{
    "experimental" : false,
    "debug" : true,
    "features": {
        "buildkit" : true
    }
}
over 4 years ago · Santiago Trujillo Report

0

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

sudo DOCKER_BUILDKIT=1 ...

over 4 years ago · Santiago Trujillo Report

0

I also received this error in Docker v19 and updating it to the latest version solved my problem.

Follow docker instruction here

over 4 years ago · Santiago Trujillo Report

0

To anyone out there that might be struggling with this sort of error: ensure that the first line of the file is '# syntax=docker/dockerfile:experimental'. This will work:

# syntax=docker/dockerfile:experimental
FROM golang:1.14.1 as builder

...    

RUN --mount=type=ssh  GOSUMDB=off go get -d -v ./...

BUT if you add a comment at the start of the file like so:

# SOME SILLY COMMENT HERE  <--- this ostensibly innocent comment ruins everything!

# syntax=docker/dockerfile:experimental
FROM golang:1.14.1 as builder

...    

RUN --mount=type=ssh  GOSUMDB=off go get -d -v ./...

Then 'syntax=...' will not be taken into account because it's no longer on the very first line. This is why you get that weird error about 'mount' below! Gah!

Hopefully this will save a few hours from the lives of a few people.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!