简体   繁体   English

Docker容器(来自其他映像的Dockerfile)立即退出-这完全是关于Dockerfile而不是命令

[英]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 这就是我要做的

  1. Copy redmine:latest docker image to custom image redmine:latest docker映像复制到自定义映像
  2. Do some extra setting and make a container 做一些额外的设置并制作一个容器
  3. Run the custom docker container 运行自定义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.

相关问题 Docker From命令Dockerfile - Docker From command Dockerfile Ubuntu Docker容器立即停止,与Dockerfile有关? - Ubuntu Docker container immediately stops, issue with Dockerfile? "make all -j"$(nproc)" 命令在 Docker 容器中有效,但在 Dockerfile 中无效 - "make all -j"$(nproc)" command works within Docker container but not in Dockerfile 保存 output 的 bash 命令从 Dockerfile 后 ZC5FD214CDD0D2B3B4272E73BFZ 容器启动 - Save output of bash command from Dockerfile after Docker container was launched 我正在尝试从dockerfile安装我的ejabberd,映像正在成功构建,但是当我按下run命令时,容器立即退出 - I am trying to install my ejabberd from dockerfile , image is building succesfully but when i hit the run command container exits immediately 从 dockerfile 构建 docker 镜像 - building docker image from dockerfile docker(1.12) 容器的运行状况检查命令(不在 Dockerfile 中!) - Health Check command for docker(1.12) container (Not in Dockerfile!) 如何将构建 docker 容器的命令放入 dockerfile? - How to put command of build docker container to dockerfile? 为什么 docker 必须从 dockerfile 创建映像,然后从映像创建容器,而不是从 Dockerfile 创建容器? - Why does docker have to create an image from a dockerfile then create a container from the image instead of creating a container from a Dockerfile? Docker 没有运行 Dockerfile 中的所有命令 - Docker didn't run all the command at Dockerfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM