Docker Community Forums

Share and learn in the Docker community.

Standard_init_linux.go:207: exec user process caused "exec format error"

I am trying to build a docker image on Windows 10 to deploy on an Ubuntu server, and I am getting the error in the title upon running it.

Here is my Dockerfile:

# first build stage to download code repos
FROM ubuntu as intermediate

# enable root ssh
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

# install git
RUN apt-get update
RUN apt-get install -y git

# save git ssh private key
ADD id_rsa /root/.ssh/id_rsa
ADD config /root/.ssh/config
RUN chmod 600 /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/config

# make sure bitbucket.org is accepted
RUN touch /root/.ssh/known_hosts
 RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

# clone code repositories
RUN git clone --single-branch --branch production git@bitbucket.org:webfootdesigns/dtms-api-service.git
RUN git clone --single-branch --branch production git@bitbucket.org:webfootdesigns/dtms-cache-service.git
RUN git clone --single-branch --branch production git@bitbucket.org:webfootdesigns/dtms-express.git
RUN git clone --single-branch --branch production git@bitbucket.org:webfootdesigns/dtms-client.git

FROM ubuntu

# copy repositories from intermediate
COPY --from=intermediate /dtms-api-service /srv/dtms-api-service
COPY --from=intermediate /dtms-cache-service /srv/dtms-cache-service
COPY --from=intermediate /dtms-express /srv/dtms-express
COPY --from=intermediate /dtms-client /srv/dtms-client

# install nodejs, npm, and git
RUN apt update -y 
RUN apt install nodejs npm git -y

# update nodejs and npm
RUN npm cache clean -f
RUN npm install npm@latest -g
RUN npm install -g n

# install required global npm packages
RUN npm install -g pm2 webpack

# load environment variables
ADD env.sh /env.sh
RUN chmod +x /env.sh
RUN chmod 700 /env.sh
# convert CRLF to LF
RUN awk '{ sub("\r$", ""); print }' ./env.sh > ./env.sh
RUN ./env.sh
RUN rm /env.sh

# install dependencies
RUN cd /srv/dtms-api-service && npm install
RUN cd /srv/dtms-cache-service && npm install
RUN cd /srv/dtms-express && npm install
RUN cd /srv/dtms-client && npm install

# build and copy client
RUN cd /srv/dtms-client && npm run build
RUN yes | cp -rf /srv/dtms-client/build/* /srv/dtms-express/public

# expose ports
EXPOSE 3001

# ENTRY: add and run the start script
ADD start.sh /
# convert CRLF to LF
RUN awk '{ sub("\r$", ""); print }' /start.sh > /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["./start.sh"]

start.sh:

#!/bin/bash
cd /srv/dtms-api-service &&
pm2 start npm -- start --name dtms-api-serivce &&
pm2 /srv/dtms-cache-service/app.js --name dtms-cache-service &&
pm2 /srv/dtms-express/app.js --name dtms-express

Build procedure:
local machine:

> docker build -t dtms-reporting .
> docker tag dtms-reporting my.container.registry/dtms-reporting
> docker push my.container.registry/dtms-reporting

server:

> docker pull my.container.registry/dtms-reporting:latest
> docker run -p 3001:3001 my.container.registry/dtms-reporting

Then I receive the error: standard_init_linux.go:207: exec user process caused "exec format error".

Edit: I figured it may have something to do with building on Windows and deploying on Ubuntu. So I tried building on the server, then tried building on my local machine with WSL, and both give the exact same result.

You can’t use awk like that to write file in-place. Check /start.sh will be empty

I am getting the same error when trying to launch a windows java maven GUI app from Linux
container on a windows machine. Any help would be appreciated.
Here is my dockerfile

FROM openjdk:8

ARG MAVEN_VERSION=3.5.4
ARG USER_HOME_DIR="/root"

WORKDIR /usr/src/app/

ADD . /usr/src/app/

RUN unzip myApp.zip -d myApp

RUN chmod -R 777 /usr/src/app/*

RUN apt-get install -y curl tar bash &&
mkdir -p /usr/share/maven &&
curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzC /usr/share/maven --strip-components=1 &&
ln -sf /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG “$USER_HOME_DIR/.m2”

ENTRYPOINT ["/usr/src/app/myApp/myApp.exe"]