Docker Compose build fails with failed to parse platform: "" is an invalid OS component on Windows Server 2019 + Kali Linux #3303
|
Hi everyone, I installed Windows Server 2019, Kali Linux, and Docker. When I try to run the project with: I get the following error: bash It seems the problem is related to this line in the Dockerfile:
From what I understand, $BUILDPLATFORM is empty or not being detected correctly in my environment. My environment My question Do I need to: set BUILDPLATFORM manually, Thanks. |
Replies: 1 comment
|
Hii MrMiningIR, $BUILDPLATFORM is a special variable that Docker only fills in automatically when BuildKit is doing the build. If the build falls back to the old "classic" builder, that variable stays empty - and --platform="" is invalid, which is exactly this error. This almost always happens with the legacy Python docker compose (v1) binary which matches the error format you are seeing (ERROR: Service 'X' failed to build). On Kali, apt install docker-compose still often pulls in this old v1 package instead of the modern Compose plugin, and v1 doesn't reliably wire up BuildKit. Fix:
sudo apt remove docker-compose
sudo apt install docker-compose-plugin
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1(add these to ~/.bashrc to persist)
docker compose up --buildIf it still fails, check docker version. Anything below 20.10 should be updated, since BuildKit support needs a reasonably recent Docker Engine. You don't need to edit the Dockerfile or remove --platform=$BUILDPLATFORM as that line is correct and standard for multi stage cross platform builds. The fix belongs on the tooling side (Compose V2 + BuildKit), not the Dockerfile itself. |
Hii MrMiningIR,
$BUILDPLATFORM is a special variable that Docker only fills in automatically when BuildKit is doing the build. If the build falls back to the old "classic" builder, that variable stays empty - and --platform="" is invalid, which is exactly this error.
This almost always happens with the legacy Python docker compose (v1) binary which matches the error format you are seeing (ERROR: Service 'X' failed to build). On Kali, apt install docker-compose still often pulls in this old v1 package instead of the modern Compose plugin, and v1 doesn't reliably wire up BuildKit.
Fix: