Failed build with Dockerfile "returned a non-zero code: 4"

Hi: I try build with dockerfile, receive error “returned a non-zero code: 4”, anex steps

docker build --build-arg user=was1 --build-arg group=was1 --build-arg URL=http://192.168.43.238/sw -t ndtar -f Dockerfile.prereq .
Sending build context to Docker daemon 23.55 kB
Step 1 : FROM centos
Trying to pull repository docker.io/library/centos … latest: Pulling from library/centos
Digest: sha256:1b9adf413b3ab95ce430c2039954bb0db0c8e2672c48182f2c5b3d30373d5b71
Status: Downloaded newer image for docker.io/centos:latest

—> 28e524afdd05
Step 2 : MAINTAINER Kavitha Suresh Kumar kavisuresh@in.ibm.com
—> Using cache
—> b5eca41e5930
Step 3 : RUN yum install -y sh bash unzip wget tar
—> Using cache
—> 50f8614eb7b5
Step 4 : ARG user=wassop85
—> Using cache
—> 488896793d02
Step 5 : ARG group=wassop85
—> Using cache
—> f0253d471562
Step 6 : RUN groupadd $group && useradd $user -g $group -m && chown -R $user:$group /var /opt /tmp
—> Using cache
—> e620b63283f7
Step 7 : USER $user
—> Using cache
—> 18a3307f5992
Step 8 : ARG URL
—> Using cache
—> 42ea5d273424
Step 9 : RUN wget -q $URL/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip && mkdir /tmp/im && unzip -qd /tmp/im /tmp/IM.zip && /tmp/im/installc -acceptLicense -accessRights nonAdmin -installationDirectory “/opt/IBM/InstallationManager” -dataLocation “/var/ibm/InstallationManager” -showProgress && rm -fr /tmp/IM.zip /tmp/im
—> Running in d9a42e53eb5a
The command ‘/bin/sh -c wget -q $URL/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip && mkdir /tmp/im && unzip -qd /tmp/im /tmp/IM.zip && /tmp/im/installc -acceptLicense -accessRights nonAdmin -installationDirectory “/opt/IBM/InstallationManager” -dataLocation “/var/ibm/InstallationManager” -showProgress && rm -fr /tmp/IM.zip /tmp/im’ returned a non-zero code: 4
[root@laplinux8 install]# echo $?
1

Helpme please

Break up that RUN line into a few different ones so that you can figure out which command is returning error code 4. Once you know that, you should be able to troubleshoot it a bit better.

2 Likes

Hi Jeff, Im Break Up and recive error in command wget, when running command out the docker the command wget is OK, maybe is a bug in docker with varibles, check

Wget Out docker
[root@laplinux8 tmp]# ls -ls /tmp/IM.zip
ls: cannot access /tmp/IM.zip: No such file or directory
[root@laplinux8 tmp]# wget -q http://laplinux8/sw/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip
[root@laplinux8 tmp]# ls -ls /tmp/IM.zip
132688 -rw-r–r-- 1 root root 135872014 Mar 21 16:08 /tmp/IM.zip

With Docker Buid

[root@laplinux8 install]# docker build --build-arg user=was1 --build-arg group=was1 --build-arg URL=http://laplinux8/sw -t ndtar -f Dockerfile.prereq .
Sending build context to Docker daemon 24.06 kB
Step 1 : FROM centos
—> 778a53015523
Step 2 : MAINTAINER Kavitha Suresh Kumar kavisuresh@in.ibm.com
—> Using cache
—> 11611cf24fde
Step 3 : RUN yum install -y sh bash unzip wget tar
—> Using cache
—> 59b318521e7e
Step 4 : ARG user=wassop85
—> Using cache
—> a68184c2a8be
Step 5 : ARG group=wassop85
—> Using cache
—> 49d6ca74b772
Step 6 : RUN groupadd $group && useradd $user -g $group -m && chown -R $user:$group /var /opt /tmp
—> Using cache
—> 5f5346acc87b
Step 7 : USER $user
—> Using cache
—> d65a40b118e6
Step 8 : ARG URL
—> Using cache
—> 77c1e15d0c84
Step 9 : RUN wget -q $URL/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip
—> Running in 6b2ebd3589dd
The command ‘/bin/sh -c wget -q $URL/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip’ returned a non-zero code: 4
[root@laplinux8 install]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b2ebd3589dd 77c1e15d0c84 "/bin/sh -c 'wget -q " 10 seconds ago Exited (4) 7 seconds ago tender_engelbart

Helpme please

To test that hypothesis, maybe change your RUN line to have the URL hardcoded instead of relying on the ARG expansion:

RUN wget -q http://laplinux8/sw/Install_Mgr_v1.6.2_Lnx_WASv8.5.5.zip -O /tmp/IM.zip

If that works, then that tells you there is a problem with the build arg. if it has the same problem, that that is likely not the cause.

https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html - this has a list of wget’s exit code meanings.

Hi Jeff:

  The problem is the FW in my nerwork, open the port in FW and access the files with wget for docker network.

The ligh was Exit-Status

4 Network failure.

Thanks

Hi,

I face the same issue(returned with non-zero code 4 i.e. network failure) with wget .
Can you please let me know how to open the port in FW i.e. what command needs to be added to my docker file(I am getting this problem when building Dockerfile).

Thanks in advance