Avoid Common Mistakes When Running Your First Docker Container

Docker always sounded cool—containers, isolation, "works on my machine" problems solved. But for a long time, I didn’t really get it.

So, I finally decided to try it hands-on—and wow, I learned a lot more from breaking things than from reading docs.

Here’s how I built and ran my **first Docker container—**a simple NGINX web server—and what went wrong along the way.

What I Wanted to Do

  • Create a simple static HTML file

  • Build a Docker image using NGINX

  • Run the container locally

  • Access it in the browser on localhost

Tools I Used

  • Docker (installed on my Windows machine using Docker Desktop)

  • Basic HTML page (index.html)

  • NGINX as base image

Step-by-Step Guide

Step 1: Create a Simple index.html

<h1>Hello from Dockerized NGINX!</h1>

Saved it in a folder.

Step 2: Create a Dockerfile

FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html

Step 3: Build the Docker Image docker build -t my-nginx-site .

Step 4: Run the Container docker run -d -p 8080:80 my-nginx-site

Then I opened http://localhost:8080 and…

“This site can’t be reached.”

I spent 30 minutes trying random fixes.

🐞 What Went Wrong

  1. Docker Desktop wasn’t running—I forgot to start it. 💀

  2. My index.html was actually named Index.html — case matters in Linux-based containers

  3. Port 8080 was already in use by another service

What I Did to Fix It

  • Restarted Docker Desktop

  • Renamed file correctly

  • Used a different port:

       docker run -d -p 9090:80 my-nginx-site
    

Boom! 💥 It worked!

Thanks for reading!
Hope this helped you in your Docker journey. More hands-on posts coming soon.

📌 Connect with me on Linkedin

Join our WhatsApp channel here

0
Subscribe to my newsletter

Read articles from Shivanand Biradar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shivanand Biradar
Shivanand Biradar