skip to Main Content

I got a legacy project running with docker-compose. A year ago it was starting with the configuration below.

Now it’s throwing an error:

exec /usr/local/bin/docker-entrypoint.sh: exec format error

I would like to run the container with the CMD configuration. I found in the web to add #!/bin/bash is required to avoid this error, which I added to the Dockerfile.

There is no custom docker-entrypoint.sh defined. As far as I understand the docs there needs to be either an entrypoint or a command.

The main purpose of a CMD is to provide defaults for an executing
container. These defaults can include an executable, or they can omit
the executable, in which case you must specify an ENTRYPOINT
instruction as well.

Dockerfile

#!/bin/bash

#nodejs
FROM node:11.15
ENV NODE_VERSION 11.15

#app directory
WORKDIR ./

#mongodb tools
RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add -
RUN echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list
RUN apt-get update
RUN apt-get install -y mongodb

RUN apt-get install nano

#nodejs packages
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install --ignore-scripts sharp
RUN npm install --only=production

COPY . .

RUN mkdir -p /logs/

# wait for mongoDB launch
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.1/wait /wait
RUN chmod +x /wait

#port of the app
EXPOSE 8080

CMD /wait && npm run dockerServer

Docker Compose

version: "3"
services:
    watchtower:
        container_name: watchtower
        image: v2tec/watchtower
        env_file:
             - watchtower.env
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /root/.docker/config.json:/config.json
        command: --interval 30
        restart: always
    mongo:
        container_name: mongo
        ports:
            - '27017:27017'
        volumes:
            - '/temp/im/docker/mongo/data:/data/db'
            - '/temp/im/docker/backup:/data/backup'
        image: mongo
        restart: always
    core:
        container_name: core
        ports:
            - '8080:8080'
        env_file:
            - core.env
        depends_on:
            - "mongo"
        volumes:
            - '/temp/im/docker/logs:/data/logs'
            - '/temp/im/docker/backup:/data/backup'
        image: index.docker.io/regname/core:beta
        logging:
            driver: "json-file"
            options:
                max-file: '5'
                max-size: '10m'
        restart: always

EDIT: I changed the title to make it better discoverable.

2

Answers


  1. Try to change FROM:

    FROM --platform=linux/amd64 node:11.15
    

    There is a good explanation.

    Login or Signup to reply.
  2. Building on an M1 and deploying to Kubernetes gave me the same error:

    exec /usr/local/bin/docker-entrypoint.sh: exec format error

    The answer above fixed it for me as well:

    FROM –platform=linux/amd64 node:18

    Up and running.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search