For example, my operating system is Ubuntu 18.04, and I built an image based on Ubuntu 24.04 on this system. During the image build, I compiled a C program P inside the image. Later, I run this container and the program P on Ubuntu 18.04. Is there a possibility of issues such as the program crashing? My assumption is that there might be a program crash. During compilation, the C program is likely linked with the higher version of glibc from Ubuntu 24.04. When running the program, ChatGPT told me that the dynamic linking will use the glibc from the container's file system. Now, if a function from glibc calls a system call that does not exist in Ubuntu 18.04 (my understanding is that system calls made by the program in the container are directly requested to the host), could this potentially cause the program to error or crash?
Is there a possibility of issues such as the program crashing?
Yes.
ChatGPT told me that the dynamic linking will use the glibc from the container's file system
Dynamic linking will use whatever libraries it resolves when starting the binary.
If the binary is started in container, it will be container's library. If the binary is started on the host, it will be host libraries.
if a function from glibc calls a system call that does not exist in Ubuntu 18.04 (my understanding is that system calls made by the program in the container are directly requested to the host), could this potentially cause the program to error or crash?
Kernel has system calls. Kernel is shared between docker and host. There "exists" the same system calls in both environments.
If you link your program with a library, for example glibc, and use functions or symbols that exist in that library but do not exist in some other version of that library, you typically see errors from dynamic linker (see man ld.so
) like: /lib64/libc.so.6: version `GLIBC_2.14' not found , Error /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found , https://superuser.com/questions/537683/how-to-fix-lib-x86-64-linux-gnu-libc-so-6-version-glibc-2-14-not-found . These errors are not specific to glibc, it can be any shared library.
See: How compatible are different versions of glibc? , How can I link to a specific glibc version? .