Juneyoung Oh
Juneyoung Oh

Reputation: 7652

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.

Upvotes: 0

Views: 304

Answers (1)

Colwin
Colwin

Reputation: 2685

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.

Upvotes: 1

Related Questions