-
Build and start the services:
docker-compose up --build
-
Verify the services:
- Access the backend directly at:
http://localhost:8000 - Access through Nginx proxy at:
http://localhost:8080
- Access the backend directly at:
-
View running containers:
docker ps
-
Stop services:
docker-compose stop
-
Restart services:
docker-compose restart
-
Remove containers and networks:
docker-compose down
-
Update the
app.pyfile:return "Hello, Docker Compose! Updated Backend Response."
-
Rebuild and restart the service:
docker-compose up --build
-
Verify the updated response.
-
Modify
nginx/default.confto include a custom error page:error_page 404 /custom_404.html; location = /custom_404.html { root /usr/share/nginx/html; internal; }
-
Reload Nginx:
docker-compose restart nginx
-
Test the custom 404 error by visiting an invalid path:
http://localhost:8080/nonexistent.
-
Scale the backend service to 3 instances:
docker-compose up --scale backend=3
-
Observe the container distribution:
docker ps
-
Test load balancing (update Nginx config if required).
-
Stop and remove all containers, networks, and volumes:
docker-compose down -v
-
Optionally, remove built images:
docker rmi python-backend
- Understand the structure of a
docker-compose.ymlfile. - Learn how to define and build services in Docker Compose.
- Explore service dependencies, volume mounts, and network configurations.
- Modify and restart services dynamically.
- Experiment with scaling and load balancing.
- Develop debugging and troubleshooting skills with Docker Compose.