Running docker-compose build --no-cache
will fail if one of the Dockerfile commands returns a non-zero exit code. However running docker build --no-cache
will return successfully in the same condition.
Example:
Dockerfile has command RUN npm install libxmljs
:
npm
will return code 137
(a warning) from this command
docker-compose
will exit at this stage while docker
does not.
I can provide more details of the builds if necessary.
I believe you are mistaken:
Dockerfile
FROM busybox:latest
RUN exit 137
RUN echo "ok"
$ docker build .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM busybox:latest
---> 8c2e06607696
Step 1 : RUN exit 137
---> Running in 804b53a341ac
INFO[0000] The command [/bin/sh -c exit 137] returned a non-zero code: 137
$ echo $?
1
Looks like docker build also exits as soon as it hits a failure.
Hmm, I can't get this to re-occur now after doing an upgrade to 1.3.0 RC3. It could have been an edge case between versions.
I'll reopen if it pops up again.
For anyone encountering this, it appears to be a race condition when running out of memory on the host.
@timfallmk Ah, thanks !!!
This error can also be recreated by removing a container from the Kitematic interface during a build.
Thank you, @timfallmk! That solved the problem for me :smile:
+1 when low on memory
This also happens when renaming a container within Kitematic during a build.
I got the same error while running out of disk space during a build.
Bumping up my droplet's RAM from 512MB to 2GB fixed it as well.
Clear your Cache, it helped me.
https://net2.com/how-to-clean-up-unused-docker-containers-images-and-volumes/
Most helpful comment
For anyone encountering this, it appears to be a race condition when running out of memory on the host.