Port mapping in Compose
📖 Scenario: You are setting up a simple web application using Docker Compose. The application runs inside a container and listens on port 80. To access it from your computer's browser, you need to map the container's port 80 to a port on your computer.
🎯 Goal: Learn how to write a Docker Compose file that maps a container port to a host port so you can access the application from your browser.
📋 What You'll Learn
Create a Docker Compose file named
docker-compose.ymlDefine a service called
webapp using the nginx imageMap container port 80 to host port 8080 using port mapping
💡 Why This Matters
🌍 Real World
Port mapping is essential to access applications running inside containers from your computer or other devices on the network.
💼 Career
Understanding Docker Compose port mapping helps in deploying and managing containerized applications in development and production environments.
Progress0 / 4 steps