Delay for connecting to docker containers after their creation

Hi,

We’re in a use case that we create docker containers on-demand and then immediately after send some requests to it. The docker container exposes the RServe that is a TCP server. We create the docker container remotely through docker-java client.

We really that most of time, immediately sending a request to the RServe hosted by docker containers receive a timeout or connection reset error. But, if we put a delay (e.g. 1 second) between the moment docker-java returns the info of the created docker container and the moment we send the request to the RServe, most of errors are removed.

So I’m wondering how to explain such behavior, is this due to the way RServe behaves? Is there a way to get docker containers synchrously (only after it’s fully started up and running)?

thx,
pola