运行 base image 失败

来源:3-3 DIY一个Base Image

三湘浪子

2019-06-17

图片描述

你好!老师。
上述操作都是在Centos 7.4中操作;已经成功的创建了base images,但是缺无法正常执行,百度了一圈没找到相应的答案,看提示好像是没有匹配到相应的文件或者目录,这个是什么意思? 还请老师有时间能解答一二,万分感谢!

写回答

3回答

麦兜搞IT

2019-06-20

编译的时候一定要加 -static

[vagrant@localhost ~]$ gcc hello.c -o hello  -static
[vagrant@localhost ~]$ ls
Dockerfile  hello  hello.c
[vagrant@localhost ~]$ docker build -t test .
Sending build context to Docker daemon  868.9kB
Step 1/3 : FROM scratch
 --->
Step 2/3 : ADD hello /
 ---> Using cache
 ---> dbb689ce285c
Step 3/3 : CMD ["/hello"]
 ---> Using cache
 ---> e3cee979b3f8
Successfully built e3cee979b3f8
Successfully tagged test:latest
[vagrant@localhost ~]$ docker run -it test
hello docker
[vagrant@localhost ~]$


0
0

三湘浪子

提问者

2019-06-18

  是的;老师我所有的操作都跟下面的操作一模一样,还请老师查看,我早上又复现了一遍昨天的过程,我觉得和您的操作没什么太大的区别,但是build出来的内容就是无法run。我的虚拟机可以远程,如果老师方便远程的话,我就将相应的账号口令发给您。

//img.mukewang.com/szimg/5d081dcb00018f6a16570134.jpg

//img.mukewang.com/szimg/5d081dcb0001f7d718710326.jpg

//img.mukewang.com/szimg/5d081dcc0001fb5118300455.jpg

//img.mukewang.com/szimg/5d081dcc0001771f07290399.jpg


0
2
三湘浪子
已经发您邮箱了,请及时查看,谢谢!
2019-06-19
共2条回复

麦兜搞IT

2019-06-18

请问您在centos里直接运行 ./hello 是可以的么?

0
0

系统学习Docker 践行DevOps理念

无论你是开发、测试还是运维,Docker都是你的必备技能。

3297 学习 · 1896 问题

查看课程