user5940735
user5940735

Reputation: 15

Docker container exits immediately despite Service Running

Similar questions seem to exist but none of them with clear answer (at least not to me). I've an LDAP Server inside a container which comes with bin/start-ds file. The problem is the container exits as soon as the shell script is finished. I'd understand the exit if script was simply printing a message, but in my case it starts a process. And since a process is running, i'd expect my container to run indefinitely as I started it in detach mode. But this is not the case and it exits immediately. Any pointers would be really appreciated. Below is my simple Dockerfile:

FROM unboundid-base:0.2
MAINTAINER helloworld

CMD ["/home/unboundid/UnboundID-DS/bin/start-ds"]

Upvotes: 1

Views: 662

Answers (3)

Richard
Richard

Reputation: 11

I run all of the UnboundID server products in docker containers for dev/test/troubleshooting. My Dockerfile CMD line is:

CMD ${UBID_HOME}/bin/start-${UBID_PRODUCT};/bin/bash

As long as you leave a foreground process running the container will not exit and what better process to leave around than a shell to interact with the server.

Upvotes: 0

Yogesh D
Yogesh D

Reputation: 1666

There can be two reason:

  1. Add --nodetach

CMD ["/home/unboundid/UnboundID-DS/bin/start-ds", "--nodetach"]

  1. Other reason why container exits immediately after you run it, is lack of resources. You might have enough resources, but there are multiple containers running at the same time which is consuming your resources. Or you are just running your container, but probably that container needs more resources to run and you are falling short of it.Allocate more resources, increase your ram and memory and trying running your container again.

Hope this helps.

Upvotes: 2

Slawomir Jaranowski
Slawomir Jaranowski

Reputation: 8527

As I guess, you use: http://docs.oracle.com/cd/E19623-01/820-6171/startds.html

So according to documentation add: --nodetach option

CMD ["/home/unboundid/UnboundID-DS/bin/start-ds", "--nodetach"]

Upvotes: 1

Related Questions