Port mapping with -p flag
📖 Scenario: You want to run a web server inside a Docker container and make it accessible from your computer's browser.To do this, you need to map the container's internal port to a port on your computer.
🎯 Goal: Learn how to use the -p flag in the docker run command to map ports from the container to your computer.
📋 What You'll Learn
Create a Docker container running the
nginx web server.Map the container's port 80 to your computer's port 8080 using the
-p flag.Verify the port mapping by running the container and checking the output.
💡 Why This Matters
🌍 Real World
Port mapping is essential when running web servers or services inside containers so you can access them from your computer or network.
💼 Career
Understanding port mapping helps you deploy containerized applications and troubleshoot network access issues in real environments.
Progress0 / 4 steps