Docker Community Forums

Share and learn in the Docker community.

Linked containers cannot connect

(Furion) #1

I have a problem where services that are linked (ie. web and database) constantly work / not work.

panic: read tcp> i/o timeout


panic: no reachable servers

The database is MongoDB:

  image: 'mongo:latest'
  command: 'mongod --auth'
    - '27017:27017'
    - '28017:28017'
  privileged: true
  restart: always

The web service connects to it like so:

    - 'MONGO_URL=mongodb://user:password@mongodb:27017/production'
    - mongodb

The problem is, sometimes it works, sometimes it doesnt, sometimes it works on service X but not on service Y, sometimes it works on 2/4 containers of service Y.

This is driving me crazy.

What do I do? Why can’t linked containers just work?

I’ve had this issue for months now. Fresh stack creation doesn’t help.

(Furion) #2

Still doesn’t work.

Nobody cares.

Yet you guys charge me hundreds of dollars.

DNS issue between containers in the same network
(Maxime Heckel) #3


First sorry for the delay
Concerning your issue, I see that you’re hardcoding the mongoldb server url in the MONGO_URL envvar. In Docker Cloud, while setting a link we’re giving you both ports and address in 2 different envvars, MONGODB_PORT_27017_TCP_PORT and MONGODB_PORT_27017_TCP_ADDR
That might help you with the connection issues to your database

(Furion) #4

@maximeheckel Unfortunately that doesn’t help.

It seems like a networking issue, because sometimes it works, sometimes it doesn’t. It just stops working randomly.

The only thing that seems to work is to use public endpoint instead of private networking…