Docker运行命令没有这样的文件或目录

莫赫德·阿洛玛(Mohd Alomar)

我使用编写了一个c ++应用程序clioncmake以编译和运行该项目。从终端或clion运行项目时,该项目运行完美。

我需要构建一个Docker Image来部署该项目,这是我第一次使用Docker。所以我创建了DockerFile

FROM gcc:5.4

# remove cmake

RUN apt-get update \
 && apt-get remove --purge -y \
    cmake \
 && apt-get autoremove -y && apt-get autoclean -y \
 && apt-get clean \
 && 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 \
 && mkdir src \
 && curl -s $cmake_sources | tar -xz --strip-components=1 -C src \
 && cd src \
 && ./bootstrap \
 && make -j8 \
 && make install \
 && cd .. \
&& rm -rf src
RUN pwd
WORKDIR /home/mohd/project/MaggotProxyTest
COPY . /home/mohd/project/MaggotProxyTest
RUN apt-get update && 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"]

然后我使用创建图像

sudo docker build -t my_app .

并且它正确地执行了所有步骤,并且如终端所示,编译了项目。

构建日志:

sudo docker build -t app_2 .
Sending build context to Docker daemon  371.2kB
Step 1/17 : FROM gcc:5.4
 ---> b87db7824271
Step 2/17 : RUN apt-get update  && apt-get remove --purge -y     cmake  && apt-get autoremove -y && apt-get autoclean -y  && apt-get clean  && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 0c23ca9008a7
Step 3/17 : ARG cmake_sources="https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz"
 ---> Using cache
 ---> df7eca2dfdec
Step 4/17 : LABEL cmake-version=3.7.0
 ---> Using cache
 ---> 659f8e671fc0
Step 5/17 : RUN cd /opt  && mkdir src  && curl -s $cmake_sources | tar -xz --strip-components=1 -C src  && cd src  && ./bootstrap  && make -j8  && make install  && cd .. && rm -rf src
 ---> Using cache
 ---> e9926d53c476
Step 6/17 : RUN pwd
 ---> Using cache
 ---> eed6b41de375
Step 7/17 : WORKDIR /home/mohd/project/MaggotProxyTest
 ---> Using cache
 ---> f1c50d7563ae
Step 8/17 : COPY . /home/mohd/project/MaggotProxyTest
 ---> ab3cadd4f213
Step 9/17 : RUN apt-get update && apt-get install -y tree
 ---> 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
 ---> b8ee14ee0355
Step 10/17 : RUN tree -x
 ---> 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
 ---> 906c6fc16d91
Step 11/17 : RUN pwd
 ---> Running in 1a98be53a294
/home/mohd/project/MaggotProxyTest
Removing intermediate container 1a98be53a294
 ---> 6929705f2df9
Step 12/17 : RUN cmake -H. -Bbuild
 ---> 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
 ---> 39cf841de150
Step 13/17 : RUN cmake --build build -- -j3
 ---> 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
 ---> d1bb3504b194
Step 14/17 : RUN tree -x
 ---> 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
 ---> 996a495e0747
Step 15/17 : RUN stat /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
 ---> 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
 ---> 157299bfb768
Step 16/17 : RUN chmod +x /home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out
 ---> Running in 74c5fd286be5
Removing intermediate container 74c5fd286be5
 ---> bbd04a80e568
Step 17/17 : CMD ["./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out"]
 ---> Running in 2401dbf2ad3e
Removing intermediate container 2401dbf2ad3e
 ---> 00b888454e7e
Successfully built 00b888454e7e
Successfully tagged app_2:latest

当我使用运行图像时

 sudo docker run -p 4000:80 my_app

错误消息是:

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 
米奇

您已在此处更改了当前目录:

WORKDIR /home/mohd/project/MaggotProxyTest

您运行的命令基于相对路径而不是绝对路径:

CMD ["./home/mohd/project/MaggotProxyTest/build/CMakeFiles/3.7.0/CompilerIdCXX/a.out"]

这导致寻找可执行文件:

/home/mohd/project/MaggotProxyTest/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"]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

运行docker时没有这样的文件或目录

没有这样的文件或目录:'docker':在本地模式下运行sagemaker studio时的'docker'

使用ssh运行远程命令,获取“ bash:/ dev / fd / 63:没有这样的文件或目录”

ENOENT:运行npm list -g -depth 0命令后,没有这样的文件或目录

实时生成:chroot:无法运行命令'/ usr / bin / env':没有这样的文件或目录

git init命令显示“没有这样的文件或目录”

bash 节点命令:没有这样的文件或目录

DD命令上没有这样的文件或目录错误

Git sh.exe & Docker 运行(没有这样的文件或目录)

NPM 运行开发。ENOENT:没有这样的文件或目录

运行脚本错误:没有这样的文件或目录

capistrano无法运行ssh:没有这样的文件或目录

没有这样的文件或目录 buildozer 调试运行

Docker进行投掷查找:'':没有这样的文件或目录

Docker + Java -VSTS没有这样的文件或目录

在docker build中没有这样的文件或目录

Docker-没有这样的文件或目录

docker chmod没有这样的文件或目录

Docker 构建错误:没有这样的文件或目录

docker COPY 失败:没有这样的文件或目录

Docker Compose:.env:没有这样的文件或目录/ NodeJS

Docker - 没有这样的文件或目录(dotnetcore)

Bash-没有这样的文件或目录,即使目录存在并且先前的命令可以正确运行

没有这样的文件或目录“文件”

Bash:在 Linux 上运行带有 node.js 的 shell 命令时没有这样的文件或目录

rm没有这样的文件或目录

没有这样的文件或目录

没有这样的文件或目录?

列表:没有这样的文件或目录