No access to AWS RDS from AWS ECS Docker Container

I have a spring boot app packaged in docker image(based on openjdk:8-jdk-alpine). As a datasource i want to use RDS. I configured postgresql RDS instance and i have access to it from my local box.
However when i deploy app to ECS i have the following issue: from EC2 instance i can access 5432 port:

nmap -Pn -p 5432
5432/tcp open  postgresql

But from the docker container started on this instance i cannot access RDS:

  • docker - cannot find aws credentials in container although they exist
  • Elastic Beanstalk Multicontainer Docker environment: no entries in etc/hosts for lined containers
  • How to push to AWS EC2 Service Container from a specific git branch (ie 'staging')
  • AWS: docker container cannot connect to external website on SSL
  • AWS Elastic Beanstalk container_commands in Python 3.4 Docker Container
  • Deploy Docker environment on Elastic Beanstalk
    5432/tcp closed postgresql

    Both RDS and EC2 instance are within same VPC. Security group for RDS allow incoming connections from all ip addresses. I tried to start docker container with –net=host and it didn’t help. RDS endpoint seems to be not visible from container

    Could anyone suggest what can be adjusted/changed?

  • How to COPY / ADD resources via a Dockerfile for privileged users?
  • How to check if the docker image has all the files?
  • Cannot run JHipster docker
  • running mongoexport from inside one container to another within a docker-compose stack
  • docker out of disk space
  • docker exec command with Popen in Python
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.