A practical local stack uses one service for MongoDB, one for the Express API, and one for the React development server. Keep browser addresses separate from Compose service names.
Connect the services
If your database service is named mongo, use mongodb://mongo:27017/app from the API container. The browser runs outside the Compose network, so use a published local API address or a frontend development proxy. Keep database data in a named volume and restrict any published ports to the development machine.
Verify startup and persistence
Run docker compose config and docker compose up --build. Check service logs, open the UI, and exercise a read and write against disposable data. Configure a database health check or make the API retry on startup. Verify the record still exists after a normal restart.
