Problem with ADD <git ref> - How to switch to labs channel?

When I try and add a git repo to my image with ADD I get the error:

ERROR: failed to solve: instruction ADD <git ref> requires the labs channel

Unless I have missed something, the documentation all seems to suggest that ADD <git ref> is stable and supported. Why would I see this error? I also cannot see anything about how to switch to the “labs” channel.

I am running RHEL8 and my docker version is:

$ docker --version
Docker version 24.0.7, build afdd53b

Have you tried to search for “docker labs channel” on google? This is the first result for me:

this part is about “Labs channel”:

Dockerfile reference about git ref

It shows an example:

# syntax=docker/dockerfile:1
FROM alpine
ADD --keep-git-dir=true /buildkit

The first line is not just a comment, but the buildkit syntax version. It is indeed not the labs channel, but it could be that the error message is misleading and it just doesn’t have the syntax version or not correctly.

Or your docker client version is good, but the daemon is not. Or you are trying a specific syntax which is not supported yet even though git ref would be supported but not that way.

These are just guesses without seing what you did, but ŰI hope the documentation about the labs channel will help.

Thank you, it is strange I couldn’t find it but all that was coming up when I googled was irrelevant. I must have been using a bad search term.

I was indeed missing the syntax line. Thanks.

Do you know if it is possible to clone without recursing the submodules?

I don’t know, I assume this buildkit feature was for simple cases. I would use multi-stage build and in the first stage I would install git or use an image that already has it, clone the project, then in the second stage I would copy the project from the first stage.Then you have all the features git has and you can prepare the project any way before copying it to the final stage without producing multiple image layers.