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 is accepted
RUN touch /root/.ssh/known_hosts
 RUN ssh-keyscan >> /root/.ssh/known_hosts

# clone code repositories
RUN git clone --single-branch --branch production
RUN git clone --single-branch --branch production
RUN git clone --single-branch --branch production
RUN git clone --single-branch --branch production

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
RUN chmod +x /
RUN chmod 700 /
# convert CRLF to LF
RUN awk '{ sub("\r$", ""); print }' ./ > ./
RUN ./
RUN rm /

# 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

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

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


> 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 / 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


WORKDIR /usr/src/app/

ADD . /usr/src/app/

RUN unzip -d myApp

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

RUN apt-get install -y curl tar bash &&
mkdir -p /usr/share/maven &&
curl -fsSL$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

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