Not able to access RDS in my spring boot application inside docker

I wanted to dockerize my spring boot application. I used

docker build -t <Name> .

to build my project and then try to run it. But my spring boot application gives Communication link failure and is not able to connect to the rds database. I have setup database url correctly in properties file and my application is inside same VPC as the RDS. My docker file is:

FROM maven:3.5.2-jdk-8-alpine AS MAVEN_TOOL_CHAIN
COPY pom.xml /tmp/
WORKDIR /tmp/
RUN mvn verify clean --fail-never
COPY src /tmp/src/
RUN mvn package -DskipTests

FROM tomcat:8.0.51-jre8-alpine
COPY --from=MAVEN_TOOL_CHAIN /tmp/target/<ProjectName>.war $CATALINA_HOME/webapps/<ProjectName>.war
COPY ./conf/* $CATALINA_HOME/conf/
CMD ["catalina.sh","run"]

Stack trace of the error im getting is below:

2019-03-14 14:17:03.400  WARN 1 --- [pool-3-thread-1] o.h.e.j.s.SqlExceptionHelper             : SQL Error: 0, SQLState: 08S01

2019-03-14 14:17:03.400 ERROR 1 --- [pool-3-thread-1] o.h.e.j.s.SqlExceptionHelper             : Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2019-03-14 14:17:03.400  INFO 1 --- [pool-3-thread-1] c.d.c.s.c.CampaignAnalyticsService       : error in updating analytics Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
2019-03-14 14:17:03.400  INFO 1 --- [pool-3-thread-1] c.d.c.s.c.CampaignAnalyticsService       : [543, Send, Announcement, -, Sukhna:, Run, for, fun]
2019-03-14 14:17:03.401  INFO 1 --- [pool-3-thread-1] c.z.h.HikariDataSource                   : HikariPool-1 - Starting...
2019-03-14 14:17:04.402 ERROR 1 --- [pool-3-thread-1] c.z.h.p.HikariPool                       : HikariPool-1 - Exception during pool initialization.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

I use the following command to run my image :

docker run -p 8081:8000 -p 3306:3306 <Name>

Source: StackOverflow