This guide explains, in simple language, how to deploy an HTML website using Docker inside WSL Ubuntu.
Your HTML files can exist in Windows. Open Ubuntu terminal and navigate to them:
cd /mnt/c/Users/YourName/Desktop/myproject
Use ls to ensure index.html is inside the directory.
Create a Dockerfile using:
nano Dockerfile
Paste the following:
FROM nginx:latest
COPY . /usr/share/nginx/html
Save → CTRL + S, Exit → CTRL + X.
docker build -t my-html-site .
This creates an image called my-html-site.
Expose port 3000 and map it to nginx port 80:
docker run -d -p 3000:80 --name my-container my-html-site
Go to:
http://localhost:3000
Your HTML website is now running inside a Docker container 🎉
Reason: Docker Desktop is not connected with WSL.
Solution:
bind: port is already allocated
Solution: Use another port:
docker run -d -p 3001:80 --name my-container my-html-site
Conflict: The container name is already in use
Solution A — Remove old container:
docker rm -f my-container
Solution B — Use new name:
docker run -d -p 3000:80 --name my-container-v2 my-html-site
Reasons:
index.html fileFix:
docker ps
Check correct container & port mapping.