I try to build a Dockerfile and I get this :
Linking CXX executable ../../../../bin/clang
collect2: error: ld terminated with signal 9 [Killed]
make[2]: *** [bin/clang-3.2] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make: *** [all] Error 2
Typically it means that I don't have enough memory. So how do I run docker build with a bigger memory (or swap ?)
Thanks :)
Did you try increasing memory available for docker via Docker > Preferencess... > Advanced > Ram. It defaults to only 2 GB (on mac).
When you are building the image docker has access to all the memory in the system.
I would recommend you not to compile while building the image, the union file system is slow and I have noticed it can run out of hard drive space pretty quickly.
What I do when I need to package an executable is to set up a container with all the necessary dependencies for compilation and then I run it with the source code mounted in a shared volume.
Once the code is compiled I move the executable into another folder where I have another Docker files that ADDs the executable into a minimal base image(like scratch or busy box).
By doing this I save time in compilation and I end up with a much smaller image.
Buy a new RAM stick? :)
More seriously, you are probably running on a VM? You need to go change the settings of your virtual machine and increase the RAM size.
In VirtualBox, it is under Settings -> System -> Motherboard -> Base Memory.
By default, Docker has no memory limitation, so if you are out of memory, you need to increase the host's capacity.
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