Step-by-step commands and explanations. Follow in order. Designed for Windows users with WSL2.
youruser@DESKTOP:~$.sudo apt update && sudo apt upgrade -y
sudo apt install curl wget vim net-tools unzip -y
sudo apt install git -y # Configure identity git config --global user.name "Your Name" git config --global user.email "you@example.com" # Verify git --version git config --list
mkdir -p ~/myapp && cd ~/myapp
~/myapp. Use pwd to
confirm your location.# Option A (recommended) echo '<h1>Hello from Docker!</h1>' > index.html # Option B (escape the ! if needed) echo "<h1>Hello from Docker\!</h1>" > index.html # Verify cat index.html
! as history; use single quotes or escape it. Check the
file with cat.# Create and open Dockerfile nano Dockerfile # Paste this inside Dockerfile FROM nginx:alpine COPY index.html /usr/share/nginx/html/index.html EXPOSE 80 # Save and exit (Ctrl+O, Enter, Ctrl+X)
# Add your Linux user to the docker group sudo usermod -aG docker $USER # Apply group change without logout (temporary) newgrp docker # Or run with sudo (temporary) sudo docker build -t myapp .
docker group allows running Docker without
sudo. You may need to log out and back in.docker build -t myapp .
myapp. If pull fails, continue to networking troubleshooting below.
docker run -d -p 8080:80 myapp # Confirm running containers docker ps
docker ps to see it.# On the Windows host # Open: http://localhost:8080
ping -c 4 google.com curl -v https://registry-1.docker.io/v2/If name resolution fails, verify your VM/WSL network mode (NAT recommended) or fix DNS (/etc/resolv.conf) temporarily by adding a public resolver like 1.1.1.1.
# Tag image docker tag myapp yourhubuser/myapp:latest # Login docker login # Push docker push yourhubuser/myapp:latest
git push.