Question · NestJS course · Module 12: Containers and CI/CD

Review: Container communication in Docker Compose

How does the 'api' container connect to MongoDB in the same Docker Compose network?

Answer options

  • Via the MongoDB container's IP address
  • Via localhost:27017
  • Via the service name: mongodb:27017
  • Via an external DNS

You can check the correct answer by solving this task in the CodeWorlds game.