Skip to content

BenedictSebastian97/demo-python-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐳 Docker Web Server Challenge

🎯 Your Mission

You have been given a set of web files. Your task is to serve them using a Python HTTP server running inside a Docker container on port 52318.

Goal: When you visit http://localhost:52318 in your browser, you should see the website running from inside a Docker container!


📁 Files Provided

You should have these files in your project directory:

  • index.html - Main webpage
  • style.css - Styling
  • script.js - JavaScript functionality
  • data.json - Sample JSON data
  • readme.txt - Text file

✅ Verify: Make sure all files are in your current directory before starting!


🎯 Challenge Requirements

  1. Container: Use Ubuntu as your base operating system
  2. Port: The server must run on port 52318
  3. Access: You must be able to access the website from your host browser
  4. Method: Use Python's built-in HTTP server module

🗺️ Roadmap (What You Need to Figure Out)

Step 1: Research Docker Basics

You need to learn:

  • How to run an Ubuntu container
  • How to map ports from container to host
  • How to get an interactive terminal inside the container

🔍 Search for: "docker run ubuntu interactive", "docker port mapping"

Step 2: Getting Files Into Container

You need to choose ONE method:

Option A: Volume Mounting (Easier for development)

  • Link your current directory to a folder inside the container
  • Changes to files on your computer appear immediately in container

Option B: Copy Files (More realistic)

  • Copy files from your computer into the running container
  • Files exist independently inside the container

Option C: Create a Dockerfile to automate the entire process (Production ready)

🔍 Search for: "docker volume mount", "docker cp command", "CMD or ENTRYPOINT"

Step 3: Prepare the Container Environment

You need to:

  • Install Python 3 inside the Ubuntu container
  • Navigate to where your files are located

🔍 Search for: "install python ubuntu apt", "ubuntu package manager"

Step 4: Start the Web Server

You need to:

  • Use Python's built-in HTTP server module
  • Serve files on the correct port
  • Make sure it's accessible from outside the container

💡 Helpful Tips: Python's built-in HTTP server starts: "python3 -m http.server 52318"

🔍 Search for: "python http.server module", "python -m flag"


💡 Helpful Tips & Hints

🐳 Docker Tips

  • The basic command structure is: docker run [options] [image] [command]
  • Use -it flags for interactive terminal access
  • Use -p flag for port mapping (format: host_port:container_port)
  • Use -v flag for volume mounting (format: host_path:container_path)
  • Use --name to give your container a friendly name

🐧 Ubuntu Container Tips

  • Package manager command: apt
  • Always run apt update before installing packages
  • Use apt install -y package_name to avoid interactive prompts
  • Python 3 package name is usually python3

🐍 Python Server Tips

  • Python has a built-in web server module
  • Use the -m flag to run modules as scripts
  • The module name is http.server
  • You can specify the port as an argument
  • Default behavior is to serve files from current directory

🌐 Port & Access Tips

  • Container port and host port can be the same number
  • Use localhost or 127.0.0.1 to access from your browser
  • Make sure no other service is using your chosen port
  • The server will serve files from whatever directory you start it in

🔧 Troubleshooting Tips

  • Use docker ps to see running containers
  • Use Ctrl+C to stop the server
  • Use exit to leave the container
  • If port is busy, stop other containers: docker stop container_name

🎯 Success Criteria

You'll know you succeeded when:

✅ You can run a Docker container with Ubuntu
✅ The container has Python 3 installed
✅ Your web files are accessible inside the container
✅ Python HTTP server is running on port 52318
✅ You can visit http://localhost:52318 and see your website
✅ All files load correctly (HTML, CSS, JS, JSON)
✅ The JavaScript button works when clicked


🆘 Getting Stuck?

If you're completely stuck, here are some gentle nudges:

🔍 Hint 1: Starting a container (click to expand)

You need a command that:

  • Runs Ubuntu
  • Gives you interactive access
  • Maps port 52318 from container to host
  • Either mounts your current directory OR allows you to copy files later
🔍 Hint 2: Installing Python (click to expand)

Inside the Ubuntu container:

  1. Update the package list first
  2. Install python3 package
  3. The installation command should answer "yes" automatically
🔍 Hint 3: Python server (click to expand)

The command format is: python3 -m [module_name] [port_number]

The module you want serves HTTP and is built into Python.

🔍 Hint 4: File access (click to expand)

Make sure your Python server starts in the same directory where your HTML files are located!


Good luck! Remember: The best way to learn is by experimenting. Don't be afraid to try things and make mistakes! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published