How to connect to specific local MongoDB instance in Spring Boot Dockerised application?

I have developed simple Spring Boot Application that performs CRUD operations using MongoDB as database. I have deployed that application in Docker but I get null values while doing GET Request for any items stored in MongoDB. Some of the files required for Docker are provided below:

Dockerfile:

  VOLUME /tmp
  ADD build/libs/Spring-Boot-MongoDB-0.0.1-SNAPSHOT.jar SpringMongoApp.jar
  ENTRYPOINT ["java", "-Dspring.data.mongodb.uri=mongodb://mongo:27018/otp","-jar","/SpringMongoApp.jar"]

docker-compose.yml:

version: "3"
services:
  api-database:
    image: mongo:3.2.4
    container_name: "springboot-mongo-app"
    ports:
      - "27018:27017"
    environment:
      MONGO_INITDB_ROOT_DATABASE: otp
    networks:
      - test-network

  api:
    image: springboot-api
    ports:
      - "8080:8080"
    depends_on:
      - api-database
    networks:
      - test-network

networks:
  test-network:
    driver: bridge

application.properties:

spring.data.mongodb.host=api-database

When I checked the MongoDb Docker container using container ID, it is automatically getting connected to test database but not to otp database which I have mentioned in environment section of docker-compose.yml file.

Source: StackOverflow