简体   繁体   中英

Docker Container(Dockerfile from other image) immediately exit - It is all about Dockerfile not command

I am trying to run Redmin via docker .

Here is what I am going to do

  1. Copy redmine:latest docker image to custom image
  2. Do some extra setting and make a container
  3. Run the custom docker container

So I made Dockerfile like

FROM redmine
CMD ["echo", "Redmine is ready!"]

Then I built image with docker build -t test . .(In the Dockerfile folder)

After that, docker run -d --name=test -p 8080:3000 test .

I expected can find test docker container is run state, but it is exit(0) .

How can I make this container keep alive?

FYI, docker run -d --name=test -p 8080:3000 redmine works fine.

Within your docker image CMD can be used only once. 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. At the moment your CMD only executes echo as soon as that command is executed your container will exit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM