DEV Community

Janak Shrestha
Janak Shrestha

Posted on

Troubleshoot Docker Container Issue

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 8085 on App Server 1. Confirm that the command curl http://localhost:8085/ works on App Server 1.


Step-by-Step Investigation

1. SSH into Application Server 1

ssh tony@stapp01
Enter fullscreen mode Exit fullscreen mode

Password: Ir0nM@n


3. Check the container status

sudo docker ps | grep nautilus
Enter fullscreen mode Exit fullscreen mode

If the container isn't running, check all containers:

sudo docker ps -a | grep nautilus
Enter fullscreen mode Exit fullscreen mode

4. Verify Volume Mapping

Check the container's volume configuration:

Method 1: Using docker inspect

sudo docker inspect nautilus | grep -A 5 -B 5 "Mounts"
Enter fullscreen mode Exit fullscreen mode

Method 2: Simple check

sudo docker inspect nautilus | grep -i "source\|destination"
Enter fullscreen mode Exit fullscreen mode

This should show:

  • Source: /var/www/html (host path)
  • Destination: /usr/local/apache2/htdocs (container path)

5. Verify Host Volume Contents

Check if the host volume has content:

ls -la /var/www/html/
Enter fullscreen mode Exit fullscreen mode

If there's an index.html or other website files, check them:

cat /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

6. Verify Container Volume Contents

Check the container's mounted volume:

sudo docker exec nautilus ls -la /usr/local/apache2/htdocs/
Enter fullscreen mode Exit fullscreen mode

Check if the website file exists:

sudo docker exec nautilus cat /usr/local/apache2/htdocs/index.html
Enter fullscreen mode Exit fullscreen mode

7. Check Port Mapping

Verify the container's port mapping:

sudo docker port nautilus
Enter fullscreen mode Exit fullscreen mode

Or using docker inspect:

sudo docker inspect nautilus | grep -A 10 "PortBindings"
Enter fullscreen mode Exit fullscreen mode

Look for port mapping showing 8085 mapped to container's port 80 (or 443).


8. Test Website Accessibility

Test from the host:

curl http://localhost:8085/
Enter fullscreen mode Exit fullscreen mode

Test with verbose output for more details:

curl -v http://localhost:8085/
Enter fullscreen mode Exit fullscreen mode

Check if Apache/HTTP server is responding:

curl -I http://localhost:8085/
Enter fullscreen mode Exit fullscreen mode

9. Check if the website is accessible from the container itself

sudo docker exec nautilus curl http://localhost/
Enter fullscreen mode Exit fullscreen mode

Common Issues and Solutions

Issue Possible Cause Solution
Volume not mounted correctly Wrong path or missing -v flag Check docker run command and remount
Host volume empty No files in /var/www/html/ Add website files to host directory
Port not accessible Wrong port mapping or Apache not running Check docker port and container logs
Website returns error Apache configuration issue Check container logs: docker logs nautilus
Container not running Container crashed or stopped Start container: docker start nautilus

Additional Troubleshooting

Check Container Logs

sudo docker logs nautilus
Enter fullscreen mode Exit fullscreen mode

Check Apache Processes Inside Container

sudo docker exec nautilus ps aux | grep httpd
Enter fullscreen mode Exit fullscreen mode

Test with Different Methods

# Test with curl and follow redirects
curl -L http://localhost:8085/

# Test with wget
wget -O- http://localhost:8085/
Enter fullscreen mode Exit fullscreen mode

Expected Successful Output

If everything is configured correctly:

  1. Volume Mapping should show:

    • Source: /var/www/html → Destination: /usr/local/apache2/htdocs
  2. Port Mapping should show:

    • 0.0.0.0:8085 → container port 80
  3. curl http://localhost:8085/ should return the website content (HTML, text, etc.)

Top comments (0)