0

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.

Juneyoung Oh
  • 7,318
  • 16
  • 73
  • 121
  • 1
    Your container runs the CMD and exits. That is why you get this behavior. – tgogos May 19 '17 at 07:26
  • Take a look at this: [http://stackoverflow.com/a/30209974/1561148](http://stackoverflow.com/a/30209974/1561148) – tgogos May 19 '17 at 07:27
  • @tgogos To me, `FROM` keyword feels little bit unclear. According to [document](https://docs.docker.com/engine/reference/builder/#from), it is about basic image. So I have presumed that running `test` image will execute original jenkins `Dockerfile` `CMD`. So I thought it should execute `CMD ["rails", "server", "-b", "0.0.0.0"]`. So is there any way to execute Dockerfile `CMD` command of the original image? – Juneyoung Oh May 19 '17 at 07:36
  • Possible duplicate of [Docker container will automatically stop after "docker run -d"](http://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d) – Holger May 19 '17 at 07:43

1 Answers1

1

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.

Colwin
  • 2,655
  • 3
  • 25
  • 25