Docker Community Forums

Share and learn in the Docker community.

Self-developed TCP server hosted in java docker container stops immediately!

docker

(Khtaheri) #1

I am to host a TCP server, developed by Java, inside a java docker container.

All what I have in the dockerfile is a copy command for the server application and the bash file, which used to run the server.

However, the server is stopped some seconds after running the container?

I use the following command for running the container:

docker run -d -p 2701:2701 --name app_test_con_1 app_test_img_1

And this is the bootstrap command in the dockerfile: CMD ["/workspace/one_click.sh"]

Is there any way to keep server running for ever? Since it does that if I run it with the same .sh files in the host OS; Of course as long as the terminal is not closed.


(Ranjandas) #2

Hi,

Can you show the contents of one_click.sh. Are you sending your tcp server to background in the script?

Try to run the java app in foreground which will probably fix your issue.

Regards


(Khtaheri) #3

Hi,

Thanks for your reply!

Actually, one_click.sh script calls another expect script which runs the server and automatically enters server’s password . However, all commands in this scenario are executed in foreground unless expect sends processes to the background by default!!

Kind regards