【发布时间】:2014-07-19 15:41:04
【问题描述】:
对于 c/c++ 源代码,我可以信任 Ubuntu 14.04 主机中用于 redhat6.4 的 docker 容器中的构建吗?还是我需要考虑的任何限制?
我们正在尝试使用 docker 服务于不同的操作系统平台来编译源代码,因为 docker 中的技术是共享主机操作系统的内核,请参阅相关问题What is the relationship between the docker host OS and the container base image OS?
- 我的主机操作系统是ubuntu 14.04(易于安装docker),内核是
3.13.0-24-generic - 我的应用平台是redhat 6.4(内核是
2.6.32-358.el6.x86_64)
当我为 Ubuntu 的 RHEL 创建容器时,内核也更新为 3.13.0-24-generic。
我的应用程序是基于 c/c++ 和 java 的。
我认为java对于编译的.jar文件不会有任何问题,因为它是基于jvm的。
而对于 c/c++ 代码,我理解它主要依赖于libc 类型的共享库,而不依赖于内核,因此是否可以将此编译后的代码用于真正的 redhat 环境。
此设置仅用于开发,不用于生产,生成的二进制文件应该安装在带有 RHEL 或 VM 的真正独立机器上。
那么我需要考虑什么?
可能是更多与 lxc 相关的问题。
更新以添加一些示例
我下载了gameoflife代码https://github.com/rvsjoen/game-of-life,在两个系统都编译,找这个案例,因为md5是一样的,结果一样,可信。
这是虚拟机中的redhat 6.4系统
[root@redhat game-of-life-master]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
[root@redhat game-of-life-master]# uname -a
Linux redhat 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64x86_64 GNU/Linux
[root@redhat]# ldd gol
linux-vdso.so.1 => (0x00007fffaeaa8000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x00000033fa000000)
libc.so.6 => /lib64/libc.so.6 (0x00000033f9c00000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00000033fb800000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000033f9800000)
/lib64/ld-linux-x86-64.so.2 (0x00000033f9400000)
[root@redhat]# md5sum gol
4f3245d3d61b1c73e48537dd612d37c3 gol
这是 docker 容器中的 redhat
bash-4.1# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
bash-4.1# uname -a
Linux f51c7b4e80aa 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
bash-4.1# ldd gol
linux-vdso.so.1 => (0x00007fff5e3c2000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f2e84863000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2e844d0000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f2e842ae000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2e840aa000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2e84a8e000)
bash-4.1# md5sum gol
4f3245d3d61b1c73e48537dd612d37c3 gol
c/c++代码有什么例外吗?
【问题讨论】: