I understand my C++ application must be built for the OS of the container in which it will run. I see many examples, including Docker’s hello-world where a build environment is created within a container like this:
host$ docker run --rm -it -v $PWD:/build ubuntu:16.04 container# apt-get install build-essential container# cd /build container# gcc -o hello hello.c
My question is, if I have “hello” already built by a non-Docker Ubuntu 16 VM, or hello built by a “bare metal” server running Ubuntu 16, is that binary safe to install and run in a ubuntu:16.04 Docker image? Or is there a requirement to compile all my code within a Docker container? I have not seen documentation or examples that the former (building outside of Docker for same OS) is safe/supported.
I do understand that if my hello depends on shared libraries, etc, I must install those shared libraries into the target Docker image for my hello to run.