Skip to content

Repository files navigation

MicroservicesLearning

two-service Docker Compose setup

             Your PC
               │
    ┌──────────┴──────────┐
    │                     │

localhost:7000 localhost:7004 │ │ ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ ProductService│◄─────│ OrderService │ │ :8080 │ HTTP │ :8080 │ └───────────────┘ └───────────────┘ ▲ │ └─────────────────────┘ Docker network

Docker commands

Build

docker compose up -d --build

Start

docker compose up -d

Stop

docker compose down

Docker setup

Postman │ │ HTTP localhost:7004 ▼ ┌──────────────────────┐ │ OrderService │ │ container :8080 │ └──────────┬───────────┘ │ │ HTTP │ productservice-container:8080 ▼ ┌──────────────────────┐ │ ProductService │ │ container :8080 │ └──────────────────────┘

Docker commands

Check active containers

docker ps

Start both containers

docker start orderservice-container
docker start productservice-container

Stop both containers

docker stop orderservice-container
docker stop productservice-container

Stop and remove the old container

docker stop orderservice-container
docker rm orderservice-container

Start the new container

docker run -d `
  --name orderservice-container `
  --network microservices-network `
  -p 7004:8080 `
  -e "Services__ProductService=http://productservice-container:8080" `
  orderservice:latest