简体   繁体   中英

Dockerized app throws read operation timed out error and exits

I've an express application that takes data from an IronMQ push queue. I've Dockerized this app and on running the application in a Docker Container, after some idle time say 20-30 mins, the App throws an error and exits out:

Error: read tcp 192.168.59.3:50346->192.168.59.103:2376: read: operation timed out

My boot2docker ip --> 192.168.59.103

I've forwarded the port at 3000.

I've tried using process object to catch uncaught exception but to no help.

Note: I've ran the app outside of docker on my local, and the app runs fine without throwing an error and logging out. So the problem seems to with docker.

As it turns out, when you execute the docker run command in the attached mode ie with the -a parameter or wiihout the -d parameter, something like:

docker run -a <imageID> or docker run <imageID>

Docker detaches from the container by default after sometime and runs the container in detached mode. Meaning your application runs fine in the background.

Hence the error: timed out

Note: This is not explicitly mentioned in the docker docs, so thought this could be documented here for future reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM