[英]Docker Container(Dockerfile from other image) immediately exit - It is all about Dockerfile not command
I am trying to run Redmin
via docker
. 我试图运行
Redmin
通过docker
。
Here is what I am going to do 这就是我要做的
redmine:latest
docker image to custom image redmine:latest
docker映像复制到自定义映像 So I made Dockerfile
like 所以我做了
Dockerfile
FROM redmine
CMD ["echo", "Redmine is ready!"]
Then I built image with docker build -t test .
然后我使用
docker build -t test .
构建映像docker build -t test .
.(In the Dockerfile
folder) (在
Dockerfile
文件夹中)
After that, docker run -d --name=test -p 8080:3000 test
. 之后,
docker run -d --name=test -p 8080:3000 test
。
I expected can find test
docker container is run
state, but it is exit(0)
. 我希望可以找到
test
docker容器处于run
状态,但它是exit(0)
。
How can I make this container keep alive? 我怎样才能使这个容器活着?
FYI, docker run -d --name=test -p 8080:3000 redmine
works fine. 仅供参考,
docker run -d --name=test -p 8080:3000 redmine
可以正常工作。
Within your docker image CMD can be used only once. 在您的docker映像中,CMD只能使用一次。 If you have more than one, only the last one will run.
如果您有多个,则只会运行最后一个。
You will need to add the 您将需要添加
CMD ["rails", "server", "-b", "0.0.0.0"]
As the cmd for your custom image to run the server. 作为用于自定义映像的cmd来运行服务器。 At the moment your CMD only executes echo as soon as that command is executed your container will exit.
目前,您的CMD仅在执行该命令后才执行echo,因此您的容器将退出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.