Back to Engineering Notes
DockerEngineering Note

3. Volume Mapping & Access on Web Server

Identify and resolve issues where a Docker container fails to stay running, stops unexpectedly, or is misconfigured, with or without removing the container.

🎯 Objective

Identify and resolve issues where a Docker container fails to stay running, stops unexpectedly, or is misconfigured, with or without removing the container.


🧠 Common Symptoms

docker ps shows no running containers
Container status = Exited
Application not accessible via browser or curl
Logs show shutdown signals (e.g., SIGWINCH)

🔍 Step-by-Step Troubleshooting

1️⃣ Check Running Containers

plain text
dockerps

2️⃣ Check All Containers (Including Stopped)

plain text
dockerps-a

3️⃣ Inspect Logs

plain text
docker logs <container_name>

🧩 Log Analysis

⚠️ Warning (Safe)

plain text
AH00558: Could not reliably determine the server's fully qualified domain name

✔ Not critical


❌ Critical Issue

plain text
caught SIGWINCH, shutting down gracefully

❗ Container started → then exited


# 🛠️ Fix Without Removing Container (When Possible)

✅ Case 1 — Container Stopped Only

plain text
dockerstart <container_name>

✔ Works if:

Configuration is already correct
No runtime crash

⚠️ Case 2 — Minor Internal Config Fix

plain text
docker exec-it <container_name>bash

Example:

plain text
echo"ServerName localhost" >> /usr/local/apache2/conf/httpd.conf

✔ Useful for:

Quick debugging
Temporary fixes

❗ Not persistent (lost if container is removed)


# ❌ When You MUST Recreate Container

🚫 Cannot Fix Without Removing

Wrong port mapping (p)
Wrong volume mapping (v)
Incorrect image or startup configuration

👉 Docker limitation: these settings are immutable after creation


🔥 Recreate Container (Correct Way)

plain text
dockerrm-f <container_name>

docker run-d \
--name nautilus \
-p8085:80 \
-v /var/www/html:/usr/local/apache2/htdocs \
  httpd

# 🧪 Validation Steps

Verify Running

plain text
dockerps

Verify Volume Mapping

plain text
docker inspect <container_name> |grep-A10 Mounts

Verify Port

plain text
ss-tulnp |grep8085

Test Website

plain text
curl http://localhost:8085/

# 🧠 Decision Guide (Important)


# 🧪 Validation Checklist

[ ] Container is running
[ ] No critical log errors
[ ] Correct port mapping (8085 → 80)
[ ] Correct volume mapping
[ ] Website accessible via curl

# 📌 Summary

Try restart first (docker start)
If configuration is wrong → must recreate container
Use docker logs to distinguish warnings vs real failures
Use docker exec only for temporary fixes