Docker Image无法执行命令

时间:2017-04-20 11:12:54

标签: docker dockerfile

我的Dockerfile如下所示:

FROM scratch 
RUN skype

我在我的操作系统中安装了skype,当我尝试使用以下命令构建docker时:

sudo docker build -t tryskyped .

它说

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM scratch
 ---> 
Step 2/2 : RUN skype
 ---> Running in 0ecf7c719567
container_linux.go:247: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
oci runtime error: container_linux.go:247: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"

如果我没有错,它应该像/bin/sh -c skype那样执行。当我手动尝试这个时,我可以看到Skype打开了 我对此非常陌生,我只是尝试使用docker.Please help

1 个答案:

答案 0 :(得分:0)

您的Dockerfile不执行任何操作,因为它没有要执行的CMD或ENTRYPOINT。 Dockerfile具有配置阶段(RUN,ADD,COPY等)和启动阶段,具有ENTRYPOINT和CMD 例如,Nginx图像引用的Dockerfile的最后一行包含

摘自

https://github.com/nginxinc/docker-nginx/blob/0c7611139f2ce7c5a6b1febbfd5b436c8c7d2d53/mainline/jessie/Dockerfile

CMD ["nginx", "-g", "daemon off;"]

检查What is the difference between CMD and ENTRYPOINT in a Dockerfile?

CMD的文档

https://docs.docker.com/engine/reference/builder/#cmd

用于ENTRYPOINT

https://docs.docker.com/engine/reference/builder/#entrypoint