docker container in EC2 cannot connect to elasticCache

0

EC2 can connect to elasticache,but docker container in EC2 cannot connect to elasticache unless i set the network_mode=host.But i want to use docker swarm to deploy the services,so i shouldn't set the network_mode=host,how can i do it

1개 답변
0

Hello hy_galen,

When you use network_mode=host, your containers will use the underlying host's network namespace. Therefore, it is equivalent to running your application on an EC2 instance wrt networking.

If you do not specify the above parameter, your containers running in the swarm cluster will be connected to the underlying host's docker_gwbridge network by default. I believe the issue could be related to the docker network setup in your swarm cluster.

Docker modifies the iptables on your nodes to provide network isolation. If you have configured docker daemon settings in /etc/docker/daemon.json, make sure you have not set iptables=false as this will break your container networking. For more info, refer this doc.

I found a stackoverflow issue that is similar to yours. Try to follow the steps provided and see if it helps in finding the root cause.

profile pictureAWS
지원 엔지니어
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠