Running bash script in ENTRYPOINT: exec user process caused: exec format error

Viewed 1399

I am building and running a Linux-based Docker image in Windows 10, but struggling to use the container's entrypoint to use a bash script.

Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS builder
RUN curl -fsSL https://get.pulumi.com | sh
WORKDIR /app
COPY ./MyProject ./
RUN ls
RUN chmod +x pulumi-go.sh
ENTRYPOINT ["./pulumi-go.sh"]

pulumi-go.sh:

#!/bin/bash
echo Hello world

And I get the following error when running docker run --rm -it myproject:latest:

standard_init_linux.go:228: exec user process caused: exec format error

Things I tried:

  • Removed windows line endings from the bash script
  • Using #!/bin/sh and #!/bin/ash

Side finding... see the docker build output when I add a RUN ./pulumi-go.sh step:

#13 [9/9] RUN ./pulumi-go.sh
#13 sha256:741c439f6f65a3a2d0c70377583f4ea20120e5a4d0950396e24ce388cb04159e
#13 0.524 ./pulumi-go.sh: 1: ./pulumi-go.sh: #!/bin/bash: not found
#13 0.524 Hello world
#13 DONE 0.6s

What is not found if the script is clearly executing?

RUN bash --version tells me bash is just fine:

#11 [7/9] RUN bash --version
#11 0.517 GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)

RUN which bash:

#11 [7/9] RUN which bash
#11 0.540 /bin/bash

RUN cat /etc/os-release:

#11 [ 7/10] RUN cat /etc/os-release
#11 0.550 PRETTY_NAME="Debian GNU/Linux 10 (buster)"
#11 0.550 NAME="Debian GNU/Linux"
#11 0.550 VERSION_ID="10"
#11 0.550 VERSION="10 (buster)"
#11 0.550 VERSION_CODENAME=buster
#11 0.550 ID=debian

Viewing all characters in Notepad++:

enter image description here

If I change entrypoint to this:

ENTRYPOINT ["/bin/bash", "-c", "./pulumi-go.sh"]

I get the following response

./pulumi-go.sh: line 1: #!/bin/bash: No such file or directory
Hello world

Hex dump of first line in pulumi-go.sh:

#13 [ 9/10] RUN od -tx1 ./pulumi-go.sh | head -n 1
#13 0.572 0000000 ef bb bf 23 21 2f 62 69 6e 2f 62 61 73 68 0a 0a
0 Answers
Related