DEV Community

Cover image for 5.Troubleshoot Docker Container Issue
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

5.Troubleshoot Docker Container Issue

Lab Information

An issue has arisen with a static website running in a container named nautilus on App Server 1. To resolve the issue, investigate the following details:

Check if the container's volume /usr/local/apache2/htdocs is correctly mapped with the host's volume /var/www/html.

Verify that the website is accessible on host port 8080 on App Server 1. Confirm that the command curl http://localhost:8080/ works on App Server 1.
Enter fullscreen mode Exit fullscreen mode

Lab Solutions

πŸ”‘ Step 0: Login to Application Server 1

ssh tony@stapp01

Password:

Ir0nM@n

πŸ” Step 1: Check volume mapping of the container

docker inspect nautilus
Enter fullscreen mode Exit fullscreen mode

Focus on the Mounts section.

You should see something like:

"Mounts": [
{
"Source": "/var/www/html",
"Destination": "/usr/local/apache2/htdocs",
"Type": "bind"
}
]

βœ… This confirms the volume is correctly mapped.

πŸ” Step 2: Verify port mapping

Still inside docker inspect output, check Ports:

"Ports": {
"80/tcp": [
{
"HostPort": "8080"
}
]
}

βœ… This confirms container port 80 is mapped to host port 8080.

🌐 Step 3: Verify website accessibility (MANDATORY)

Run on App Server 1:

curl http://localhost:8080/

Expected result

[tony@stapp01 ~]$ curl http://localhost:8080/
curl: (7) Failed to connect to localhost port 8080: Connection refused
Enter fullscreen mode Exit fullscreen mode

Fix it

docker ps
docker start nautilus
docker ps
docker port nautilus
curl http://localhost:8080/
Enter fullscreen mode Exit fullscreen mode

Expected result

[tony@stapp01 ~]$ curl http://localhost:8080/
Welcome to xFusionCorp Industries!
Enter fullscreen mode Exit fullscreen mode

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)
πŸͺœ What are we checking?

We are verifying two things only:

File connection (volume mapping)

Network connection (port mapping)

πŸ“ Volume Mapping Explained

Website files live on the host:

/var/www/html

Apache inside container reads from:

/usr/local/apache2/htdocs

Volume mapping connects them like a shared folder

If mapping is correct:

Updating files on host updates website instantly

🌐 Port Mapping Explained

Apache listens on port 80 inside container

Docker exposes it as port 8080 on host

So:

curl http://localhost:8080/

means:

β€œAsk the container’s Apache server for the website.”

🧠 Exam Memory Hook

Inspect β†’ Mounts β†’ Ports β†’ Curl

If curl works, everything is wired correctly.


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)