pkl: Exec format error in Dockerfile #168

Closed
opened 2025-12-30 01:21:41 +01:00 by adam · 2 comments
Owner

Originally created by @scariabpc on GitHub (Jun 8, 2024).

Hi, I'm trying to use pkl inside of my Dockerfile. Currently the Dockerfile has something like this:

# Use the official Python image from the Docker Hub
FROM python:3.11-slim

# Install pkl.
# https://github.com/apple/pkl/releases/tag/0.25.3
ARG PKL_BINARY=pkl-linux-amd64
RUN curl -L -o /opt/pkl https://github.com/apple/pkl/releases/download/0.25.3/${PKL_BINARY} \
  || { echo 'Failed to download pkl'; exit 1; }

# Ensure pkl is executable.
RUN chmod +x /opt/pkl

# Add pkl to the PATH.
ENV PATH="/opt:${PATH}"

...

When this image runs on AWS ECS with Linux, the pkl commands work, but when I build and run the image locally on my Mac with M2 chip I get this error.

$ docker build --build-arg PKL_BINARY=pkl-macos-amd64 -f .../Dockerfile -t my-app ./
$ docker run -p 3000:3000 my-app
sh: 1: pkl: Exec format error
Originally created by @scariabpc on GitHub (Jun 8, 2024). Hi, I'm trying to use pkl inside of my Dockerfile. Currently the Dockerfile has something like this: ``` # Use the official Python image from the Docker Hub FROM python:3.11-slim # Install pkl. # https://github.com/apple/pkl/releases/tag/0.25.3 ARG PKL_BINARY=pkl-linux-amd64 RUN curl -L -o /opt/pkl https://github.com/apple/pkl/releases/download/0.25.3/${PKL_BINARY} \ || { echo 'Failed to download pkl'; exit 1; } # Ensure pkl is executable. RUN chmod +x /opt/pkl # Add pkl to the PATH. ENV PATH="/opt:${PATH}" ... ``` When this image runs on AWS ECS with Linux, the pkl commands work, but when I build and run the image locally on my Mac with M2 chip I get this error. ```bash $ docker build --build-arg PKL_BINARY=pkl-macos-amd64 -f .../Dockerfile -t my-app ./ $ docker run -p 3000:3000 my-app sh: 1: pkl: Exec format error ```
adam closed this issue 2025-12-30 01:21:41 +01:00
Author
Owner

@HT154 commented on GitHub (Jun 8, 2024):

The binary you are using is pkl-linux-amd64, which is for linux systems running Intel/amd64/x86_64 architecture processors. The build arg you are providing (pkl-macos-aarch64 is for macOS systems running on ARM processors. To run in a linux container on ARM processors, you need to use the pkl-linux-aarch64 binary.

If you are building a multi-architecture container image then you can use the TARGETARCH arg to choose the right binary to download. See the Docker documentation on how to use this arg: https://docs.docker.com/build/guide/multi-platform/

@HT154 commented on GitHub (Jun 8, 2024): The binary you are using is `pkl-linux-amd64`, which is for linux systems running Intel/amd64/x86_64 architecture processors. The build arg you are providing (`pkl-macos-aarch64` is for macOS systems running on ARM processors. To run in a linux container on ARM processors, you need to use the `pkl-linux-aarch64` binary. If you are building a multi-architecture container image then you can use the `TARGETARCH` arg to choose the right binary to download. See the Docker documentation on how to use this arg: https://docs.docker.com/build/guide/multi-platform/
Author
Owner

@bioball commented on GitHub (Jun 10, 2024):

Closing as this is not a Pkl problem (see @HT154's comments)

@bioball commented on GitHub (Jun 10, 2024): Closing as this is not a Pkl problem (see @HT154's comments)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#168