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!
You should have these files in your project directory:
index.html- Main webpagestyle.css- Stylingscript.js- JavaScript functionalitydata.json- Sample JSON datareadme.txt- Text file
✅ Verify: Make sure all files are in your current directory before starting!
- Container: Use Ubuntu as your base operating system
- Port: The server must run on port 52318
- Access: You must be able to access the website from your host browser
- Method: Use Python's built-in HTTP server module
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"
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"
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"
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"
- The basic command structure is:
docker run [options] [image] [command] - Use
-itflags for interactive terminal access - Use
-pflag for port mapping (format:host_port:container_port) - Use
-vflag for volume mounting (format:host_path:container_path) - Use
--nameto give your container a friendly name
- Package manager command:
apt - Always run
apt updatebefore installing packages - Use
apt install -y package_nameto avoid interactive prompts - Python 3 package name is usually
python3
- Python has a built-in web server module
- Use the
-mflag 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
- Container port and host port can be the same number
- Use
localhostor127.0.0.1to 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
- Use
docker psto see running containers - Use
Ctrl+Cto stop the server - Use
exitto leave the container - If port is busy, stop other containers:
docker stop container_name
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
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:
- Update the package list first
- Install python3 package
- 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! 🚀