0
0
Nginxdevops~30 mins

Container networking in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
Container Networking with Nginx
📖 Scenario: You are setting up a simple web server using Nginx inside a Docker container. To make your web server accessible from your computer, you need to configure container networking properly.
🎯 Goal: Learn how to create a Docker container running Nginx and configure its networking so that you can access the web server from your host machine.
📋 What You'll Learn
Create a Docker container running Nginx
Map the container's port 80 to the host's port 8080
Verify that the Nginx welcome page is accessible via http://localhost:8080
💡 Why This Matters
🌍 Real World
Developers and system administrators often run web servers inside containers. Proper networking setup lets them access these servers from their computers or other services.
💼 Career
Understanding container networking is essential for deploying applications in Docker and Kubernetes environments, a key skill for DevOps roles.
Progress0 / 4 steps
1
Create a Docker container running Nginx
Write the Docker command to run an Nginx container named mynginx in detached mode using the official nginx image.
Nginx
Need a hint?

Use docker run with --name to name the container and -d to run it in the background.

2
Map container port 80 to host port 8080
Modify the Docker command to map the container's port 80 to the host's port 8080 so you can access Nginx from your browser at http://localhost:8080.
Nginx
Need a hint?

Use the -p option with hostPort:containerPort format.

3
Check running containers and their ports
Write the Docker command to list all running containers with their port mappings to verify that mynginx is running and port 8080 is mapped.
Nginx
Need a hint?

Use docker ps to see running containers and their port mappings.

4
Access Nginx welcome page
Write a command to fetch the homepage from http://localhost:8080 using curl to confirm the Nginx server is accessible.
Nginx
Need a hint?

Use curl http://localhost:8080 to get the Nginx welcome page content.