I'm getting asymmetrical container discoverability with multicontainer docker on AWS. Namely, the first container can find the second, but the second cannot find the first.
I have a multicontainer docker deployment on AWS Elastic Beanstalk. Both containers are running Node servers using identical initial code, and are built with identical Dockerfiles. Everything is up to date.
Anonymized version of my Dockerrun.aws.json file:
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "firstContainer",
"image": "firstContainerImage",
"essential": true,
"memoryReservation":196,
"links":[
"secondContainer",
"redis"
],
"portMappings":[
{
"hostPort":80,
"containerPort":8080
}
]
},
{
"name": "secondContainer",
"image": "secondContainerImage",
"essential": true,
"memoryReservation":196,
"environment":
"links":[
"redis"
]
},
{
"name": "redis",
"image": "redis:4.0-alpine",
"essential": true,
"memoryReservation":128
}
]
}
The firstContainer
proxies a subset of requests to secondContainer
on port 8080, via the address http://secondContainer:8080
, which works completely fine. However, if I try to send a request the other way, from secondContainer
to http://firstContainer:8080
, I get a "Bad Address" error of one sort or another. This is true both from within the servers running on these containers, and directly from the containers themselves using wget
. It's also true when trying different exposed ports.
If I add "firstContainer"
to the "links"
field of the second container's Dockerrun file, I get an error.
My local setup, using docker-compose, does not have this problem at all.
Anyone know what the cause of this is? How can I get symmetrical discoverability on an AWS multicontainer deployment?
I got a response from AWS support on the topic.
The links are indeed one-way, which is an unfortunate limitation. They recommended taking one of two approaches:
I opted for a 3rd approach, which was to have the container that can discover the rest send out pings to inform the others of its docker-network IP address.