Report this

What is the reason for this report?

Failed to load /usr/bin/bash: exec format error

Posted on May 21, 2021

Hi, I create docker image with bash for run 2 application

#!/bin/sh
./service-linux-one

./service-linux

If I run docker local docker run -it --rm {name} all work fine. I catch error if deploy on do app

[2021-05-21T19:37:47.694599036Z] starting container: starting non-root container [bash ./run.sh]: creating process: failed to load /usr/bin/bash: exec format error


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @eaglemoor,

It looks like that you don’t have bash installed inside the container. You could instead try using sh:

RUN /bin/sh

Or alternatively, you could install bash. Depending on the Docker image that you are using you could add an install step in your Dockerfile. For example if you are using Apline as your base image this would look like this:

RUN apk update && apk add bash

If you are using Ubuntu or Debian it would need to be updated to apt update && apt install bash.

Let me know how it goes. Regards, Bobby

in case someone else comes across this. i encountered this issue when building images on the m1 max macbook (ARM64).

i believe this is because the VM host DO uses expects AMD64 only.

you can confirm this with:

docker inspect <image ID> --format '{{.Architecture}}'

# you can get image ID with
docker image ls

when built through docker desktop on macOS you get

docker inspect <image ID> --format '{{.Architecture}}'
arm64

when built on a native linux docker host you get

docker inspect <image ID> --format '{{.Architecture}}'
amd64

if you get arm64 then you will see this issue when you deploy.

here is another DO thread discussing this in detail

If you are using an Apple Silicon to build your images, you need to use amd64 images (default is arm64 on those macs which is not supported by DO)

Dockerfile

FROM --platform=linux/amd64 node:18-alpine
# Rest of your docker file...

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.