cli icon indicating copy to clipboard operation
cli copied to clipboard

Support for Podman's preprocessed dockerfiles

Open rdong8 opened this issue 6 months ago • 1 comments

podman build will apply the C preprocessor first if you give your Dockerfile a .in extension: https://docs.podman.io/en/latest/markdown/podman-build.1.html#description. This is incredibly useful if you want to have a base image for all your devcontainers with some common tools installed, and then layer on language-specific images. For example:

tools.Dockerfile:

FROM docker.io/debian:latest
RUN apt-get update && apt-get install -y vim

cpp.Dockerfile.in:

#include "tools.Dockerfile"
RUN apt-get update && apt-get install -y clang

This basically allows you to avoid having to build the base image by hand, which is not trivial since you have to manually pass in all the same flags to the builder as devcontainers-cli.

However, this causes errors with devcontainers-cli:

[2026-05-07T16:04:30.959Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/home/rdong/projects/cpp_project --filter label=devcontainer.config_file=/home/rdong/projects/cpp_project/.devcontainer/devcontainer.json
[2026-05-07T16:04:31.014Z] Stop (55 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/home/rdong/projects/cpp_project --filter label=devcontainer.config_file=/home/rdong/projects/cpp_project/.devcontainer/devcontainer.json
[2026-05-07T16:04:31.043Z] Error: Error parsing Dockerfile: Dockerfile contains no FROM instructions
[2026-05-07T16:04:31.043Z]     at vQ (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:393:12987)
[2026-05-07T16:04:31.043Z]     at xV (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:467:2349)
[2026-05-07T16:04:31.043Z]     at async Rp (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:467:1910)
[2026-05-07T16:04:31.043Z]     at async cG (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:467:608)
[2026-05-07T16:04:31.043Z]     at async A9 (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:485:4649)
[2026-05-07T16:04:31.043Z]     at async kI (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:485:5768)
[2026-05-07T16:04:31.043Z]     at async vZ (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:666:205)
[2026-05-07T16:04:31.043Z]     at async GZ (/home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:665:15080)
[2026-05-07T16:04:31.043Z]     at async /home/rdong/.vscode-remote-containers/dist/dev-containers-cli-0.460.0/dist/spec-node/devContainersSpecCLI.js:485:1917

Ideally these checks would be performed only on the preprocessed file, ie. the output of cpp -E cpp.Dockerfile.in.

rdong8 avatar May 07 '26 17:05 rdong8

Hello @rdong8 ,

Thank you for reporting the issue. We are not adding built-in preprocessing support for .in Dockerfiles at this time. As a workaround, please use initializeCommand to preprocess Dockerfile.in into a Dockerfile before the build starts. This allows the existing build flow to continue without requiring native preprocessing support.

{
	"build": {
		    "dockerfile": "Dockerfile",
             "context": "."
	},
	"initializeCommand": "cpp -P Dockerfile.in Dockerfile",
	"features": {
		"ghcr.io/devcontainers/features/github-cli:1": {
			"version": "latest"
		}
	}
}

v-Mathiyarasy avatar Jun 09 '26 10:06 v-Mathiyarasy