16

I have been working with dockerfiles for a while now but today I was working on a small project and somehow on my VScode I typed # then CTRL+SPACE on the first line I got this syntax=docker/dockerfile:experimental.

I don't understand what this does and can't find documentation about it can somebody explain what's with that weird comment.

PS I found some people using this so it's not just some random comment generated by vscode I guess.

1 Answer 1

13

It's a way to enable new syntax in Dockerfiles when building with BuildKit. It's mentioned in the documentation:

Overriding default frontends

The new syntax features in Dockerfile are available if you override the default frontend. To override the default frontend, set the first line of the Dockerfile as a comment with a specific frontend image:

# syntax=<frontend image>, e.g. # syntax=docker/dockerfile:1.2

The examples on this page use features that are available in docker/dockerfile version 1.2.0 and up. We recommend using docker/dockerfile:1, which always points to the latest release of the version 1 syntax. BuildKit automatically checks for updates of the syntax before building, making sure you are using the most current version. Learn more about the syntax directive in the Dockerfile reference.

I have used it to enable SSH Auth Sock forwarding.

3
  • 3
    So what will be the default frontend version I will be having with my docker setup. Is there any command by which I can know it from the terminal ? I am not sure if I need to update it or not. Commented Jul 15, 2022 at 9:52
  • Is it possible to define a specific image as default in daemon.json ?
    – secavfr
    Commented Jan 10, 2023 at 16:50
  • 3
    New location of documentation: docs.docker.com/build/dockerfile/frontend
    – Nick Breen
    Commented Jun 28, 2023 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.