Weird behavior: Google Compute Engine cannot trigger containers restart by itself

I’m using this library to publish app on Google Compute Engine.

nginx-proxy:
  image: jwilder/nginx-proxy
  container_name: nginx-proxy
  ports:
  - '80:80'
  - '443:443'
  volumes:
  - /var/run/docker.sock:/tmp/docker.sock:ro
  - nginx-certs:/etc/nginx/certs:ro
  - nginx-vhost:/etc/nginx/vhost.d
  - nginx-html:/usr/share/nginx/html
  labels:
  - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true
  restart: always

letsencrypt-nginx-proxy-companion:
  image: jrcs/letsencrypt-nginx-proxy-companion
  container_name: nginx-letsencrypt
  volumes:
  - /var/run/docker.sock:/var/run/docker.sock:ro
  - nginx-certs:/etc/nginx/certs
  - nginx-vhost:/etc/nginx/vhost.d
  - nginx-html:/usr/share/nginx/html
  restart: always
  depends_on:
  - "nginx-proxy"

The problem is sometimes my app is down, and I can not find out why it doesn’t restart itself, unless I do docker logs, which is super weird. Why on earth need docker logs to trigger containers restart?

Yes, all I do is in the VM instances tab of Compute Engine:

  • Click SSH to connect to the instance. After this step, server is still down.
  • As soon as I do docker logs nginx-proxy or docker logs nginx-letsencrypt or docker logs my-app, the server restarts immediately.

Those docker logs do not show any errors, so I have no clues what make the server down. Thus, I cannot even reproduce when it goes down. But the more important question is why cannot it restart itself? Any comments would be appreciated.

Source: StackOverflow