dockerportability

What are Docker's HW portability limitations?


I have only read some introductory articles - some of which may have been older and might be obsolete by now. With regard to portability these texts usually talked about different OS versions but not the actual HW. So I am wondering:

Suppose I have some existing C/C++ code library and code uses inlined x86 ASM fragments for performance optimizations (e.g. using MMX or similar ops specific to certain Intel or AMD processors), i.e. in order to run this code on a different CPU architecture (e.g. ARM64) you'd obviously have to use some kind of CPU emulation.

Would the non-portable assembly code need to be replaced before the code could be used, or could that code still be used but only on server HW that uses the respective CPU architecture, or does Docker provide any CPU emulation facilities that would allow it to actually run respective code anywhere? What would be the options available in the Docker context?


Solution

  • Docker containers run on the real CPU and uses the real kernel of the underlying OS to provide the basic environment, there is no such thing as emulation here. As such, code is constrained to the CPU architecture it was written for, just the same as if you weren't using Docker at all.

    So in this case, your code would be constrained to the specific CPUs that support those inline assembly instructions (as well as the code generated by the compiler), much like as running the code on the normal OS.

    What Docker does best is providing isolated software environment for running programs within containers so they don't interfere with each other and with the operating system, but the hardware is still the real one. An emulator of some kind would be required to run those binaries unmodified on ARM for example.