title: Dockerfile from scratch using dynamic build
body: <p><strong>The following post it too long , please be patient while going through</strong></p>
  
  <p>Hi , i'm quite new to docker and dds .</p>
  
  <p>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.</p>
  
  <p>I want to use FROM scratch in my Dockerfile as i don't need bash nor any os.</p>
  
  <p>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.</p>
  
  <p><strong>Which one is preferred or is there a rule to it?</strong></p>
  
  <p><strong>Docker Verion</strong></p>
  
  <p>Client: Docker Engine - Community<br>
   Version:           19.03.2<br>
   API version:       1.40<br>
   Go version:        go1.12.8<br>
   Git commit:        6a30dfc<br>
   Built:             Thu Aug 29 05:29:11 2019<br>
   OS/Arch:           linux/amd64<br>
   Experimental:      false  </p>
  
  <p><strong>Dockerfile when exe files are build with -static flag</strong></p>
  
  <pre><code>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"]
  </code></pre>
  
  <p><strong>The docker image gets successfully build and runs without any error</strong></p>
  
  <p><strong>BUT</strong></p>
  
  <p><strong>Dockerfile when exe files are build dynamically (without static flag)</strong></p>
  
  <p>figuring all the dependencies were to be copied as well
  checked the dependencies using  </p>
  
  <p>ldd on the exe</p>
  
  <pre><code>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"]
  </code></pre>
  
  <p><strong>Build the docker image</strong></p>
  
  <pre><code>docker build --tag dynamictest .
  </code></pre>
  
  <p><strong>But when i try to run this i get the following error</strong></p>
  
  <pre><code>docker run --rm -it dynamictest
  </code></pre>
  
  <p><strong>Error</strong><br>
  standard_init_linux.go:211: exec user process caused "no such file or directory</p>
  
  <p><strong>So , am i missing something here or is it that "FROM scratch only works with static builds"</strong></p>