问题描述
这是一个简单的Dockerfile
Here's a simple Dockerfile
FROM centos:6.6
ENTRYPOINT ["/bin/bash", "-l", "-c"]
CMD ["echo", "foo"]
不幸的是它不起作用当您运行构建的结果容器时,没有任何回音。
如果您注释掉 ENTRYPOINT
,那么它可以工作。但是,如果将 ENTRYPOINT
设置为 / bin / sh -c
,则会再次失败
Unfortunately it doesn't work. Nothing is echo'd when you run the resulting container that's built.
If you comment out the ENTRYPOINT
then it works. However, if you set the ENTRYPOINT
to /bin/sh -c
, then it fails again
FROM centos:6.6
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["echo", "foo"]
我以为这是默认的 ENTRYPOINT
一个没有定义的容器,为什么没有这样的工作?
I thought that was the default ENTRYPOINT
for an container that didn't have one defined, why didn't that work?
最后,这也有用
FROM centos:6.6
ENTRYPOINT ["/bin/bash", "-l", "-c"]
CMD ["echo foo"]
在提交问题之前,我想看看我是否在做某些事情错误?
我在我的容器内使用 rvm
需要一个登录shell正常工作。
Before I submit an issue, I wanted to see if I'm doing something obviously wrong?
I'm using rvm
inside my container which sort of needs a login shell to work right.
推荐答案
请注意,部分所述:
FROM ubuntu
CMD echo "This is a test." | wc -
,这里的shell格式更为可取。
Since echo
is a built-in command in the bash and C shells, the shell form here is preferable.
这篇关于Docker CMD当ENTRYPOINT是一个shell脚本时很奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!