The following post it too long , please be patient while going through
Hi , i'm quite new to docker and dds .
i am creating a simple code using rti-dds and docker . The code will provide me two exes one for publishing the data and other for subscribing the data.
I want to use FROM scratch in my Dockerfile as i don't need bash nor any os.
Now if i use FROM scratch do i need to have my exes statically build with the g++ -static flag or can it be done dynamically , that is without the static flag.
Which one is preferred or is there a rule to it?
Docker Verion
Client: Docker Engine - Community
Version: 19.03.2
API version: 1.40
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:29:11 2019
OS/Arch: linux/amd64
Experimental: false
Dockerfile when exe files are build with -static flag
FROM scratch
COPY rti_license.dat /
COPY USER_QOS_PROFILES.xml /
COPY /objs/x64Linux3gcc4.8.2/DynamicTest_publisher /
COPY /objs/x64Linux3gcc4.8.2/DynamicTest_subscriber /
CMD ["/DynamicTest_publisher"]
The docker image gets successfully build and runs without any error
BUT
Dockerfile when exe files are build dynamically (without static flag)
figuring all the dependencies were to be copied as well checked the dependencies using
ldd on the exe
FROM scratch
COPY rti_license.dat /
COPY USER_QOS_PROFILES.xml /
COPY /lib/x86_64-linux-gnu/libdl.so.2 /
COPY /lib/x86_64-linux-gnu/libnsl.so.1 /
COPY /lib/x86_64-linux-gnu/libpthread.so.0 /
COPY /lib/x86_64-linux-gnu/librt.so.1 /
COPY /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /
COPY /lib/x86_64-linux-gnu/libc.so.6 /
COPY /lib/x86_64-linux-gnu/libgcc_s.so.1 /
COPY /objs/x64Linux3gcc4.8.2/DynamicTest_publisher /
COPY /objs/x64Linux3gcc4.8.2/DynamicTest_subscriber /
COPY /lib64/ld-linux-x86-64.so.2 /
CMD ["/DynamicTest_publisher"]
Build the docker image
docker build --tag dynamictest .
But when i try to run this i get the following error
docker run --rm -it dynamictest
Error
standard_init_linux.go:211: exec user process caused "no such file or directory
So , am i missing something here or is it that "FROM scratch only works with static builds"