I have the following dockerfile which is very simple using Centos:latest as the base image. docker file exits on any command other than 0 as error code/code yum check-update returns a status code of 100 for successful operation
The docker file is as follows
FROM centos:latest
MAINTAINER xyz ([email protected])
ENTRYPOINT ["/bin/sh", "-lc", "ocp-indent"]
RUN yum -y check-update
When I try to build the image , the process is getting run as follows, but it gets killed without building the image successfully
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM centos:latest
latest: Pulling from library/centos
7dc0dca2b151: Pull complete
Digest:
sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
Status: Downloaded newer image for centos:latest
---> 49f7960eb7e4
Step 2/4 : MAINTAINER xyz ([email protected])
---> Running in c5284bbfb10e
---> b2334a38cc19
Removing intermediate container c5284bbfb10e
Step 3/4 : ENTRYPOINT /bin/sh -lc ocp-indent
---> Running in 55b9adafca35
---> 02df626e85d6
Removing intermediate container 55b9adafca35
Step 4/4 : RUN yum check-update
---> Running in 3f9d47e74522
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirror.its.dal.ca
* extras: centos.les.net
* updates: centos.les.net
binutils.x86_64 2.27-28.base.el7_5.1
updates
gnupg2.x86_64 2.0.22-5.el7_5
updates
python.x86_64 2.7.5-69.el7_5
updates
python-libs.x86_64 2.7.5-69.el7_5
updates
**The command '/bin/sh -c yum check-update' returned a non-zero code: 100**
yum check-update
is expected to exit with status 100 if updates are available, as described in its documentation:
check-update
Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an update. Also returns a list of the packages to be updated in list format. Returns 0 if no packages are available for update. Returns 1 if an error occurred. Running in verbose mode also shows obsoletes.
Similarly, the docker RUN
command is expected to terminate on any nonzero exit status. If you want to force the command to ignore an exit status of 100 (but still treat other failures as erroneous), you can do so as follows:
RUN yum -y check-update || { rc=$?; [ "$rc" -eq 100 ] && exit 0; exit "$rc"; }
That the Docker RUN
command treats any nonzero exit status as a failure is standard UNIX convention (the only successful exit status is 0), and is explicitly implemented in dockerfile/containerbackend.go
:
if status := <-waitC; status.ExitCode() != 0 {
close(finished)
logCancellationError(cancelErrCh,
fmt.Sprintf("a non-zero code from ContainerWait: %d", status.ExitCode()))
return &statusCodeError{code: status.ExitCode(), err: status.Err()}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With