'What is #syntax=docker/dockerfile:experimental?

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lars Nyström