Best practice - whether to use new buildkit features or try to be backwards compatible

I plan to automate in the future build jobs and use my Dockerfiles with various tools, so do you recommend to use heredoc syntax with RUN when building images from Dockerfile and new buildkit features in docker images? What’s the best practice? Should I try to write stuff backwards compatible or use new Docker features?

I’m not sure what is the backwards compatibility here. You have a tool, you have a gool that the tool supports. If you need what the tool supports and makes your life (development) easier, you use it. Once you have the image, people can use it. Doesn’t matter how you built it. What matters is what you built.

While generally true, it seems there are ways to build an image, which doesn’t work with older Docker Engine version, e.g. when you specifically configure BuilKit to use zstd compression. This would make the image incompatible with Docker Engine < v23, as they have no support for zstd compressed images.

1 Like

Thanks for bringing it up. It is important for the full picure. I was thinking about similar features to the one mentinoed in the question like special syntaxes. Of course, when it is about changing formats, that matters.

So if that was also part of the question, I would probably support Docker versions that are still considered supported and not obselete depending on the audience

The biggest problam for beginners on the other hand is how they can recognize what changes the image format and what doesn’t. If anything changes metadata like labels that other tools could rely on, that could also matter, but I could not come up with an example.

Personally, i wouldn’t bother to make any new image backward compatible. Why try to support anything that existed before you made your first image? But once you’ve made a product available to the world, it’s only polite to try to keep it compatible with the initial environment as long as possible (without creating too much work for yourself).

1 Like