1

I'm new to docker and I'm still trying to learn the conepts. On my centos machine I created a test image that would include a C-compiled executable. Based on my understanding of docker my intention and my expectation was for the image to run on centos machines only. Here is my docker file:

FROM centos:7
WORKDIR /opt/MYAPPS
COPY my_hello .
CMD my_hello

The image builds and works fine on the centos machine I created. Then I pushed this image to my repo and pulled it to another centos machine, and works correctly as well. So far so good.

As I mentioned I was expecting for this image to be limited to centos. In order to prove it I tried pulling it to other OSs, my ubuntu and my windows. To my surprise, it worked on both. Obviously I'm missing something. Either I'm not grasping the concept of docker or I'm using the wrong "FROM" image.

Ya.
  • 1,671
  • 4
  • 27
  • 53

1 Answers1

1

As I mentioned I was expecting for this image to be limited to centos.

No: What you put in the image is merely what the dependencies for your executable to run, but in the end, everything resolves to system calls.

That means your image is limited by the kernel of the host machine, since the running process is doing system call to said kernel.
(As illustrated in "The Fascinating World of Linux System Calls")

https://478h5m1yrfsa3bbe262u7muv-wpengine.netdna-ssl.com/wp-content/uploads/2015/12/image002.png

As long as the kernel (here Linux, even on Windows, through HyperV) supports your system call, your program will run on those hosts.
See more at "How can Docker run distros with different kernels?".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I guess the part the I can't get my head around is this. I heard that docker utilizes the host's resources. To me it implied that it could only run on the OS that the image was build "from". If it works on other OSs then how different is it from a full-blown VM? Oh well, I guess I'll have some reading and thinking to so. I'm accepting your answer. – Ya. Nov 03 '18 at 16:34