-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
User Story
As a DevOps engineer,
I want to define a shared Docker network in docker-compose.yml
so that backend and frontend services communicate explicitly via a dedicated network,
preventing unpredictable behavior in scaled environments.
Background
The current docker-compose.yml (lines 1-20) relies on Docker’s default bridge network, which:
- Implicitly connects services without clear dependencies.
- Risks port conflicts or misrouted traffic when scaling (e.g., multiple backend instances).
- Lacks explicit network naming, making debugging and service discovery harder.
The frontend’s App.js (line 7) hardcodes http://0.0.0.0:80/ for backend communication, which may fail if the backend’s hostname or port changes in scaled deployments.
Acceptance Criteria
- Modify
docker-compose.ymlto:- Declare a shared network (e.g.,
app_network) undernetworks. - Attach both
backendandfrontendservices to this network.
- Declare a shared network (e.g.,
- Update the frontend’s
App.jsto use the backend service name (e.g.,http://backend/) instead of0.0.0.0:80. - Validate by:
- Running
docker-compose upand confirming the frontend displays the backend’s "Hello World" message. - Scaling the backend with
docker-compose up --scale backend=2and verifying the frontend can communicate with all instances. - Inspecting the network with
docker network inspect [network_name]to confirm both services are attached.
- Running