Search code examples
dockerdocker-composedockerfile

Docker RUN: failed to resolve process when trying to build a Dockerfile


I'm trying to build a Dockerfile with below content:

FROM openjdk:8-jdk-alpine

# working directory 
WORKDIR /opt

# create directory for gatling install
RUN mkdir -p dir

# install
RUN apk add --update wget bash libc6-compat && \
mkdir -p /tmp/downloads && \
wget -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip && \
mkdir -p /tmp/archive && \
cd /tmp/archive && \
unzip /tmp/downloads/file.zip && \
mv /tmp/archive/file/* /opt/file/ && \
rm -rf /tmp/*

# change context to file directory
WORKDIR  /opt/file

# set directories below to be mountable from host
VOLUME ["/opt/file/conf", "/opt/file/results", "/opt/file/user-files"]

# set environment variables
ENV PATH /opt/path
ENV HOME /opt/HOME

ENTRYPOINT ["execScript.sh"]

When I run this command : sudo docker build -t tag:name . I got below error as:

ERROR: failed to solve: process "RUN apk add --update wget bash libc6-compat && \
mkdir ..." did not complete successfully: exit code: 139

I'm using Mac M1 Apple chip, arm64. How do I resolve this issue?

Edited: I tweak a bit by adding RUN to each line, it turns out that the faulty line was wget -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip, logging was:

Dockerfile:22
--------------------
  20 |     RUN apk add --update wget bash libc6-compat
  21 |     RUN mkdir -p /tmp/downloads 
  22 | >>> RUN wget -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip
  23 |     RUN mkdir -p /tmp/archive 
  24 |     RUN cd /tmp/archive
--------------------
ERROR: failed to solve: process "/bin/sh -c wget -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip" did not complete successfully: exit code: 139

Further debugging by jumping directly to docker using docker exec -it id sh, I get this error when re-run the whole command:

/bin/sh -c wget -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip

Turns out that wget cannot detect whole part -q -O /tmp/downloads/file.zip https://repo1.maven.org/maven2/file.zip in its command, I have tried to put this wget command into double ticks, but no use. How do I disable /bin/sh -c ?


Solution

  • It turns out that the problem comes from using Mac Apple chip, changed to a Window PC using same Dockerfile built with no issue. Only updated openjdk:19-alpine, but 8-alpine still works!