如今,我正在尝试了解Docker,但是仍然有一些不清楚的想法。
我尝试运行刚创建的镜像,这是目录;
你好(目录):
还有Dockerfile:
FROM scratch
ADD start.sh /var/
CMD ["/var/start.sh"]
start.sh:
#!/bin/bash
echo "hello world"
我已标记为正在使用:
docker build -t mozer / hello。
一旦我运行命令;
docker run mozer/hello
no such file or directory
Error response from daemon: Cannot start container f22019aabc81f29fe17e849a2c040902ccadefe6cb8a8fe2612c83fe8eda40ea: [8] System error: no such file or directory
然后运行命令:
docker run mozer/hello /bin/sh -c
exec: "/bin/sh": stat /bin/sh: no such file or directory
Error response from daemon: Cannot start container 3b54584092e70b639671aca66122a0b1f6b1e4327cb2471a8792c3b2337b0bcc: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory
您能否给我一些想法以找到解决方案?
附言:我正在使用未连接互联网的机器!
最佳答案
FROM scratch
是一个完全空的文件系统。您没有安装的库,也没有包含任何 shell 程序(例如/ bin / sh)。要将其用作基础,您需要一个静态链接的二进制文件,或者您需要安装linux发行版中随附的所有普通工具。
后者是在docker hub上的各个busybox,debian,ubuntu,centos等镜像中预先打包的。使图像以最少的基本图像运行的快速方法是将更改为,然后将FROM busybox
更改为/bin/bash
。
关于docker - 无法从头启动Docker容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42584395/