Poppy
Poppy

Reputation: 3092

Docker container does not start on executing docker run command

I have created a dockerfile for starting kafka in standalone mode. Docker build is working fine. On executing docker command docker run -p 9092:9092 -p 2181:2181 <imageID> I see that the container is not started. But there are no errors while execution. I tried to capture the logs using docker events& and could see the following

2016-02-11T04:28:44.012268995-05:00 842b99f89a846431bf1661dd40b635558a5e859727ca6953c95e323a8d221409: (from cb196b74879a) create
842b99f89a846431bf1661dd40b635558a5e859727ca6953c95e323a8d221409
2016-02-11T04:28:44.845660927-05:00 842b99f89a846431bf1661dd40b635558a5e859727ca6953c95e323a8d221409: (from cb196b74879a) start
2016-02-11T04:28:45.053143162-05:00 842b99f89a846431bf1661dd40b635558a5e859727ca6953c95e323a8d221409: (from cb196b74879a) die

I tried to open the terminal to the container using the image ID and tried to start kafka server in commandline and it is working as expected. I am not sure of the issue here. Please help.

Upvotes: 2

Views: 5717

Answers (1)

danday74
danday74

Reputation: 57205

a docker container will exit if the process on which it hangs exits. For example

CMD ./myscript.sh

will exit when the script exits BUT

CMD tail -f myfile

will not exit because the tail -f command does not exit

If you need to keep an exiting container alive then try

docker run -dti

or

docker run -dt

Upvotes: 4

Related Questions