title: Docker run command no such file or directory
body: <p>I wrote a c++ application using <code>clion</code>, <code>cmake</code> to compile and run the project. The project worked perfectly while running it from terminal or clion. </p>
  
  <p>I need to build a Docker Image to deploy the project and its my first time to use Docker. So I created the <code>DockerFile</code></p>
  
  <pre><code>FROM gcc:5.4
  
  # remove cmake
  
  RUN apt-get update \
   &amp;&amp; apt-get remove --purge -y \
      cmake \
   &amp;&amp; apt-get autoremove -y &amp;&amp; apt-get autoclean -y \
   &amp;&amp; apt-get clean \
   &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  # build latest cmake
  
  ARG cmake_sources="https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz"
  LABEL cmake-version=3.7.0
  
  RUN cd /opt \
   &amp;&amp; mkdir src \
   &amp;&amp; curl -s $cmake_sources | tar -xz --strip-components=1 -C src \
   &amp;&amp; cd src \
   &amp;&amp; ./bootstrap \
   &amp;&amp; make -j8 \
   &amp;&amp; make install \
   &amp;&amp; cd .. \
  &amp;&amp; rm -rf src
  RUN pwd
  WORKDIR /home/mohd/project/MaggotProxyTest
  COPY . /home/mohd/project/MaggotProxyTest
  RUN apt-get update &amp;&amp; apt-get install -y tree
  RUN tree -x
  RUN pwd
  #RUN cmake .
  #RUN make
  RUN cmake -H. -Bbuild
  RUN cmake --build build -- -j3
  RUN tree -x
  RUN stat /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
  RUN chmod +x /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
  CMD ["./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out"]
  </code></pre>
  
  <p>Then I build the image using </p>
  
  <pre><code>sudo docker build -t my_app .
  </code></pre>
  
  <p>And it do all steps correctly and it compile the project as shown the terminal. </p>
  
  <p>Build log: </p>
  
  <pre><code>sudo docker build -t app_2 .
  Sending build context to Docker daemon  371.2kB
  Step 1/17 : FROM gcc:5.4
   ---&gt; b87db7824271
  Step 2/17 : RUN apt-get update  &amp;&amp; apt-get remove --purge -y     cmake  &amp;&amp; apt-get autoremove -y &amp;&amp; apt-get autoclean -y  &amp;&amp; apt-get clean  &amp;&amp; rm -rf /var/lib/apt/lists/*
   ---&gt; Using cache
   ---&gt; 0c23ca9008a7
  Step 3/17 : ARG cmake_sources="https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz"
   ---&gt; Using cache
   ---&gt; df7eca2dfdec
  Step 4/17 : LABEL cmake-version=3.7.0
   ---&gt; Using cache
   ---&gt; 659f8e671fc0
  Step 5/17 : RUN cd /opt  &amp;&amp; mkdir src  &amp;&amp; curl -s $cmake_sources | tar -xz --strip-components=1 -C src  &amp;&amp; cd src  &amp;&amp; ./bootstrap  &amp;&amp; make -j8  &amp;&amp; make install  &amp;&amp; cd .. &amp;&amp; rm -rf src
   ---&gt; Using cache
   ---&gt; e9926d53c476
  Step 6/17 : RUN pwd
   ---&gt; Using cache
   ---&gt; eed6b41de375
  Step 7/17 : WORKDIR /home/mohd/project/MaggotProxyTest
   ---&gt; Using cache
   ---&gt; f1c50d7563ae
  Step 8/17 : COPY . /home/mohd/project/MaggotProxyTest
   ---&gt; ab3cadd4f213
  Step 9/17 : RUN apt-get update &amp;&amp; apt-get install -y tree
   ---&gt; Running in c633632b810f
  Get:1 http://security.debian.org jessie/updates InRelease [94.4 kB]
  Ign http://deb.debian.org jessie InRelease
  Get:2 http://security.debian.org jessie/updates/main amd64 Packages [646 kB]
  Get:3 http://deb.debian.org jessie-updates InRelease [145 kB]
  Get:4 http://deb.debian.org jessie Release.gpg [2434 B]
  Get:5 http://deb.debian.org jessie Release [148 kB]
  Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.1 kB]
  Get:7 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
  Fetched 10.1 MB in 17s (578 kB/s)
  Reading package lists...
  Reading package lists...
  Building dependency tree...
  Reading state information...
  The following NEW packages will be installed:
    tree
  0 upgraded, 1 newly installed, 0 to remove and 88 not upgraded.
  Need to get 45.9 kB of archives.
  After this operation, 102 kB of additional disk space will be used.
  Get:1 http://deb.debian.org/debian/ jessie/main tree amd64 1.7.0-3 [45.9 kB]
  debconf: delaying package configuration, since apt-utils is not installed
  Fetched 45.9 kB in 3s (15.2 kB/s)
  Selecting previously unselected package tree.
  (Reading database ... 21224 files and directories currently installed.)
  Preparing to unpack .../tree_1.7.0-3_amd64.deb ...
  Unpacking tree (1.7.0-3) ...
  Setting up tree (1.7.0-3) ...
  Removing intermediate container c633632b810f
   ---&gt; b8ee14ee0355
  Step 10/17 : RUN tree -x
   ---&gt; Running in 86327f018039
  .
  |-- AdvertisementServer.cpp
  |-- AdvertisementServer.h
  |-- ArrayQueue.h
  |-- CMakeLists.txt
  |-- Channel.cpp
  |-- Channel.h
  |-- ControlSession.cpp
  |-- ControlSession.h
  |-- Defines.h
  |-- DeviceQoSManager.cpp
  |-- DeviceQoSManager.h
  |-- Dockerfile
  |-- GlobalChannel.cpp
  |-- GlobalChannel.h
  |-- MaggotChannel.cpp
  |-- MaggotChannel.h
  |-- MaggotGarbageCollector.cpp
  |-- MaggotGarbageCollector.h
  |-- MaggotPacketQueue.cpp
  |-- MaggotPacketQueue.h
  |-- MaggotScheduler.cpp
  |-- MaggotScheduler.h
  |-- MaggotSender.cpp
  |-- MaggotSender.h
  |-- MaggotSession.cpp
  |-- MaggotSession.h
  |-- MaggotTcpPacket.cpp
  |-- MaggotTcpPacket.h
  |-- MaggotUdpChannel.cpp
  |-- MaggotUdpChannel.h
  |-- MainScheduler.cpp
  |-- MainScheduler.h
  |-- Makefile
  |-- MptcpSession.cpp
  |-- MptcpSession.h
  |-- OutOfOrderQueue.cpp
  |-- OutOfOrderQueue.h
  |-- Packets.h
  |-- Profiler.cpp
  |-- Profiler.h
  |-- ProxySocket.cpp
  |-- ProxySocket.h
  |-- RateCapped.h
  |-- Receiver.cpp
  |-- Receiver.h
  |-- Reliable.h
  |-- ReorderingQueue.cpp
  |-- ReorderingQueue.h
  |-- Retransmitter.cpp
  |-- Retransmitter.h
  |-- Running
  |-- Safe_Queue.h
  |-- Schedulable.h
  |-- Session.cpp
  |-- Session.h
  |-- SessionKey.cpp
  |-- SessionKey.h
  |-- SharedLargeBufferPool.cpp
  |-- SharedLargeBufferPool.h
  |-- SharedPool.h
  |-- TODO.txt
  |-- TcpScheduler.cpp
  |-- TcpScheduler.h
  |-- TcpSession.cpp
  |-- TcpSession.h
  |-- TimerEventManager.cpp
  |-- TimerEventManager.h
  |-- UdpScheduler.cpp
  |-- UdpScheduler.h
  |-- UdpSession.cpp
  |-- UdpSession.h
  |-- Using
  |-- Util.cpp
  |-- Util.h
  |-- VpnManager.cpp
  |-- VpnManager.h
  |-- b87db7824271
  |-- cmake_install.cmake
  |-- df7eca2dfdec
  |-- e3255b76c200
  |-- empty.c
  |-- log.txt
  |-- log.txt~
  |-- rateCap
  |-- second-
  |-- sniffer.c
  `-- socketOpt.c
  
  0 directories, 87 files
  Removing intermediate container 86327f018039
   ---&gt; 906c6fc16d91
  Step 11/17 : RUN pwd
   ---&gt; Running in 1a98be53a294
  /home/mohd/project/MaggotProxyTest
  Removing intermediate container 1a98be53a294
   ---&gt; 6929705f2df9
  Step 12/17 : RUN cmake -H. -Bbuild
   ---&gt; Running in b9ed7275783d
  -- The C compiler identification is GNU 5.4.0
  -- The CXX compiler identification is GNU 5.4.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/local/bin/c++
  -- Check for working CXX compiler: /usr/local/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/mohd/project/MaggotProxyTest/build
  Removing intermediate container b9ed7275783d
   ---&gt; 39cf841de150
  Step 13/17 : RUN cmake --build build -- -j3
   ---&gt; Running in 2f0cc83e7dfa
  Scanning dependencies of target MaggotProxy
  [ 10%] Building CXX object CMakeFiles/MaggotProxy.dir/Util.cpp.o
  [ 10%] Building CXX object CMakeFiles/MaggotProxy.dir/ProxySocket.cpp.o
  [ 10%] Building CXX object CMakeFiles/MaggotProxy.dir/VpnManager.cpp.o
  [ 13%] Building CXX object CMakeFiles/MaggotProxy.dir/UdpSession.cpp.o
  [ 16%] Building CXX object CMakeFiles/MaggotProxy.dir/UdpScheduler.cpp.o
  [ 20%] Building CXX object CMakeFiles/MaggotProxy.dir/TcpSession.cpp.o
  [ 23%] Building CXX object CMakeFiles/MaggotProxy.dir/TcpScheduler.cpp.o
  [ 26%] Building CXX object CMakeFiles/MaggotProxy.dir/SessionKey.cpp.o
  [ 30%] Building CXX object CMakeFiles/MaggotProxy.dir/Session.cpp.o
  [ 33%] Building CXX object CMakeFiles/MaggotProxy.dir/Receiver.cpp.o
  [ 36%] Building CXX object CMakeFiles/MaggotProxy.dir/MptcpSession.cpp.o
  [ 40%] Building CXX object CMakeFiles/MaggotProxy.dir/MainScheduler.cpp.o
  [ 43%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotSession.cpp.o
  [ 46%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotScheduler.cpp.o
  [ 50%] Building CXX object CMakeFiles/MaggotProxy.dir/GlobalChannel.cpp.o
  [ 53%] Building CXX object CMakeFiles/MaggotProxy.dir/Channel.cpp.o
  [ 56%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotChannel.cpp.o
  [ 60%] Building CXX object CMakeFiles/MaggotProxy.dir/SharedLargeBufferPool.cpp.o
  [ 63%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotTcpPacket.cpp.o
  [ 66%] Building CXX object CMakeFiles/MaggotProxy.dir/TimerEventManager.cpp.o
  [ 70%] Building CXX object CMakeFiles/MaggotProxy.dir/OutOfOrderQueue.cpp.o
  [ 73%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotPacketQueue.cpp.o
  [ 76%] Building CXX object CMakeFiles/MaggotProxy.dir/Retransmitter.cpp.o
  [ 80%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotUdpChannel.cpp.o
  [ 83%] Building CXX object CMakeFiles/MaggotProxy.dir/ControlSession.cpp.o
  [ 86%] Building CXX object CMakeFiles/MaggotProxy.dir/AdvertisementServer.cpp.o
  [ 90%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotSender.cpp.o
  [ 93%] Building CXX object CMakeFiles/MaggotProxy.dir/ReorderingQueue.cpp.o
  [ 96%] Building CXX object CMakeFiles/MaggotProxy.dir/MaggotGarbageCollector.cpp.o
  [100%] Linking CXX executable MaggotProxy
  [100%] Built target MaggotProxy
  Removing intermediate container 2f0cc83e7dfa
   ---&gt; d1bb3504b194
  Step 14/17 : RUN tree -x
   ---&gt; Running in fec09156925b
  .
  |-- AdvertisementServer.cpp
  |-- AdvertisementServer.h
  |-- ArrayQueue.h
  |-- CMakeLists.txt
  |-- Channel.cpp
  |-- Channel.h
  |-- ControlSession.cpp
  |-- ControlSession.h
  |-- Defines.h
  |-- DeviceQoSManager.cpp
  |-- DeviceQoSManager.h
  |-- Dockerfile
  |-- GlobalChannel.cpp
  |-- GlobalChannel.h
  |-- MaggotChannel.cpp
  |-- MaggotChannel.h
  |-- MaggotGarbageCollector.cpp
  |-- MaggotGarbageCollector.h
  |-- MaggotPacketQueue.cpp
  |-- MaggotPacketQueue.h
  |-- MaggotScheduler.cpp
  |-- MaggotScheduler.h
  |-- MaggotSender.cpp
  |-- MaggotSender.h
  |-- MaggotSession.cpp
  |-- MaggotSession.h
  |-- MaggotTcpPacket.cpp
  |-- MaggotTcpPacket.h
  |-- MaggotUdpChannel.cpp
  |-- MaggotUdpChannel.h
  |-- MainScheduler.cpp
  |-- MainScheduler.h
  |-- Makefile
  |-- MptcpSession.cpp
  |-- MptcpSession.h
  |-- OutOfOrderQueue.cpp
  |-- OutOfOrderQueue.h
  |-- Packets.h
  |-- Profiler.cpp
  |-- Profiler.h
  |-- ProxySocket.cpp
  |-- ProxySocket.h
  |-- RateCapped.h
  |-- Receiver.cpp
  |-- Receiver.h
  |-- Reliable.h
  |-- ReorderingQueue.cpp
  |-- ReorderingQueue.h
  |-- Retransmitter.cpp
  |-- Retransmitter.h
  |-- Running
  |-- Safe_Queue.h
  |-- Schedulable.h
  |-- Session.cpp
  |-- Session.h
  |-- SessionKey.cpp
  |-- SessionKey.h
  |-- SharedLargeBufferPool.cpp
  |-- SharedLargeBufferPool.h
  |-- SharedPool.h
  |-- TODO.txt
  |-- TcpScheduler.cpp
  |-- TcpScheduler.h
  |-- TcpSession.cpp
  |-- TcpSession.h
  |-- TimerEventManager.cpp
  |-- TimerEventManager.h
  |-- UdpScheduler.cpp
  |-- UdpScheduler.h
  |-- UdpSession.cpp
  |-- UdpSession.h
  |-- Using
  |-- Util.cpp
  |-- Util.h
  |-- VpnManager.cpp
  |-- VpnManager.h
  |-- b87db7824271
  |-- build
  |   |-- CMakeCache.txt
  |   |-- CMakeFiles
  |   |   |-- 3.7.0
  |   |   |   |-- CMakeCCompiler.cmake
  |   |   |   |-- CMakeCXXCompiler.cmake
  |   |   |   |-- CMakeDetermineCompilerABI_C.bin
  |   |   |   |-- CMakeDetermineCompilerABI_CXX.bin
  |   |   |   |-- CMakeSystem.cmake
  |   |   |   |-- CompilerIdC
  |   |   |   |   |-- CMakeCCompilerId.c
  |   |   |   |   `-- a.out
  |   |   |   `-- CompilerIdCXX
  |   |   |       |-- CMakeCXXCompilerId.cpp
  |   |   |       `-- a.out
  |   |   |-- CMakeDirectoryInformation.cmake
  |   |   |-- CMakeOutput.log
  |   |   |-- CMakeTmp
  |   |   |-- MaggotProxy.dir
  |   |   |   |-- AdvertisementServer.cpp.o
  |   |   |   |-- CXX.includecache
  |   |   |   |-- Channel.cpp.o
  |   |   |   |-- ControlSession.cpp.o
  |   |   |   |-- DependInfo.cmake
  |   |   |   |-- GlobalChannel.cpp.o
  |   |   |   |-- MaggotChannel.cpp.o
  |   |   |   |-- MaggotGarbageCollector.cpp.o
  |   |   |   |-- MaggotPacketQueue.cpp.o
  |   |   |   |-- MaggotScheduler.cpp.o
  |   |   |   |-- MaggotSender.cpp.o
  |   |   |   |-- MaggotSession.cpp.o
  |   |   |   |-- MaggotTcpPacket.cpp.o
  |   |   |   |-- MaggotUdpChannel.cpp.o
  |   |   |   |-- MainScheduler.cpp.o
  |   |   |   |-- MptcpSession.cpp.o
  |   |   |   |-- OutOfOrderQueue.cpp.o
  |   |   |   |-- ProxySocket.cpp.o
  |   |   |   |-- Receiver.cpp.o
  |   |   |   |-- ReorderingQueue.cpp.o
  |   |   |   |-- Retransmitter.cpp.o
  |   |   |   |-- Session.cpp.o
  |   |   |   |-- SessionKey.cpp.o
  |   |   |   |-- SharedLargeBufferPool.cpp.o
  |   |   |   |-- TcpScheduler.cpp.o
  |   |   |   |-- TcpSession.cpp.o
  |   |   |   |-- TimerEventManager.cpp.o
  |   |   |   |-- UdpScheduler.cpp.o
  |   |   |   |-- UdpSession.cpp.o
  |   |   |   |-- Util.cpp.o
  |   |   |   |-- VpnManager.cpp.o
  |   |   |   |-- build.make
  |   |   |   |-- cmake_clean.cmake
  |   |   |   |-- depend.internal
  |   |   |   |-- depend.make
  |   |   |   |-- flags.make
  |   |   |   |-- link.txt
  |   |   |   `-- progress.make
  |   |   |-- Makefile.cmake
  |   |   |-- Makefile2
  |   |   |-- TargetDirectories.txt
  |   |   |-- cmake.check_cache
  |   |   |-- feature_tests.bin
  |   |   |-- feature_tests.c
  |   |   |-- feature_tests.cxx
  |   |   `-- progress.marks
  |   |-- MaggotProxy
  |   |-- Makefile
  |   `-- cmake_install.cmake
  |-- cmake_install.cmake
  |-- df7eca2dfdec
  |-- e3255b76c200
  |-- empty.c
  |-- log.txt
  |-- log.txt~
  |-- rateCap
  |-- second-
  |-- sniffer.c
  `-- socketOpt.c
  
  7 directories, 148 files
  Removing intermediate container fec09156925b
   ---&gt; 996a495e0747
  Step 15/17 : RUN stat /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
   ---&gt; Running in 6fff7ee1a160
    File: '/home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out'
    Size: 7168        Blocks: 16         IO Block: 4096   regular file
  Device: 2eh/46d Inode: 150866      Links: 1
  Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
  Access: 2018-04-21 14:23:44.000000000 +0000
  Modify: 2018-04-21 14:23:44.000000000 +0000
  Change: 2018-04-21 14:23:45.834455655 +0000
   Birth: -
  Removing intermediate container 6fff7ee1a160
   ---&gt; 157299bfb768
  Step 16/17 : RUN chmod +x /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
   ---&gt; Running in 74c5fd286be5
  Removing intermediate container 74c5fd286be5
   ---&gt; bbd04a80e568
  Step 17/17 : CMD ["./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out"]
   ---&gt; Running in 2401dbf2ad3e
  Removing intermediate container 2401dbf2ad3e
   ---&gt; 00b888454e7e
  Successfully built 00b888454e7e
  Successfully tagged app_2:latest
  </code></pre>
  
  <p>When I run the image using </p>
  
  <pre><code> sudo docker run -p 4000:80 my_app
  </code></pre>
  
  <p>The error message is: </p>
  
  <pre><code>docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out\": stat ./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out: no such file or directory": unknown.
  ERRO[0000] error waiting for container: context canceled 
  </code></pre>