I have a task definition that defines two containers: "orion" and "mongo". The task definition launches an EC2 instance on a Bridge network mode.
The mongo container has the host and container port of: 27017, when you ssh into the instance and into the container you can see mongo is running correctly. You can also see this by checking the logs of the container.
The orion container has the host and container port of: 1026, the container is running but looking at the logs it returns this error:
time=Wednesday 01 May 12:34:38 2019.979Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongoConnectionPool.cpp[152]:mongoConnect | msg=Database Startup Error (cannot connect to mongo - doing 100 retries with a 1000 microsecond interval)
which if I understand it means it cannot connect to the mongo database.
The orion container also has this command: ["-dbhost 0.0.0.0:27017"] which is meant to register the host and port to connect to the database. I have tried all manner of '0.0.0.0','localhost','mongo' with none working.
I have ssh into each container and both can ping each other on their i.p addresses.
When I create the docker network locally with my compose file it works fine the only difference being where the command for orion is:
-dbhost mongo-cb.docker:27017
mongo-cb.docker being the alias for the mongo container.
I expect the orion container to spin up and correctly connect to the mongo database in the mongo container.
p.s I am not a docker wizard or a devops developer, so any explanations would be great alongside the how to.