My directory structure:
root
  - mongo_seed
    - Dockerfile
    - init.json
  - docker-compose.yml
  - Dockerfile
Docker compose file
version: "3"
services:
 web:
  container_name: "hgbackend"
  build: .
  image: tahashin/hgbackend:v2
  ports:
   - "3000:3000"
  links:
   - mongodb
  depends_on:
   - mongodb
 mongodb:
   image: mongo:latest
   container_name: "mongodb"
   ports:
    - "27017:27017"
 mongo_seeding:
    build: ./mongo_seed .
    volumes:
      - ./config/db-seed:/data
    links:
      - mongodb
    depends_on:
      - mongodb
docker file under mongo_seed directory
FROM mongo:latest
    COPY init.json /init.json
    CMD mongoimport --host mongodb --db alifhala --collection honcollection --type json --file /init.json --jsonArray
mongodb test data file init.json
[
  {
    "name": "Joe Smith",
    "email": "jsmith@gmail.com",
    "age": 40,
    "admin": false
  },
  {
    "name": "Jen Ford",
    "email": "jford@gmail.com",
    "age": 45,
    "admin": true
  }
]
After running docker-compose up in windows powershell database and collection is not creating and data is not dumping. After running mongo query in docker it is showing only 3 databases: local, admin, config