I composed a Mongodb service with Docker on my local machine, and the hostname is configured in docker-compose.yml with syntax container_name: mongodb
, then with the spirit of Microservice I started a RESTful API service on a lightweight embedded server, say Jetty, also locally.
The problem is that the local RESTful API service cannot communicate with the Mongodb service by using the defined Mongodb container name - mongodb
- on a local Docker container due to different network.
Questions:
- Is this a good practice, say by starting the RESTful API service just on an embedded server, esp. in production, without another Docker container differing from the Mongodb container?
- If this is a good practice, how to configure to make the RESTful API on the local embedded server have access to the Mongodb on a local Docker container?