The blog about containerisation, virtual machines and useful shell snippets and findings

jwilder nginx-proxy debug in docker

When your site did not work properly in docker do following:

  1. Check is nginx container running
docker ps -a
3fbec7a5431f        jwilder/nginx-proxy                                "/app/docker-entrypoi"   20 hours ago        Up 7 minutes                0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   nginx-proxy
  1. Check if it has proper configuration
docker exec nginx-proxy nginx -t

You should receive

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
docker exec nginx-proxy nginx -T

this shows configuration of nginx. So, no need to bash into nginx container and do cat /etc/nginx/conf.d/default.conf. It’s much faster.

  1. Check if your container and nginx container has network connection.
    If not, connect them with
docker network connect mycontainer_default nginx-proxy
  1. Check container logs
docker logs nginx-proxy -f --tail 250

That will show last 250 lines and continues to follow new data.