Docker's heredoc example for RUN is not working

I tried to implement the example provided by Docker itself (

# syntax=docker/dockerfile:1.3-labs

FROM ubuntu:20.04

echo "Hello" >> /hello
echo "World!" >> /hello

using docker version

~/test$ docker --version
Docker version 20.10.22, build 3a2c30b

but it throws the error

~/test$ docker build .
Sending build context to Docker daemon  2.048kB
Error response from daemon: dockerfile parse error line 6: unknown instruction: ECHO

I've also tried it with dockerfile versions 1, 1.3, 1.4, 2, 2.0. Nothing worked. Am I doing something wrong or is it just not working (yet)?


  • You need to use the buildkit toolkit for that:

    $ DOCKER_BUILDKIT=1 docker build .