0

I have a docker container which keeps restarting

           Name                         Command                 State                  Ports
--------------------------------------------------------------------------------------------------------
wenotecloudstorage_flask_1   /bin/sh -c /usr/local/bin/ ...   Restarting
wenotecloudstorage_nginx_1   nginx -g daemon off;             Up           0.0.0.0:2083->443/tcp, 80/tcp

I wish I have an easy way, to look at error log on why it is restarting.

I read on Docker: Container keeps on restarting again on again

I try

docker logs --tail 50 --follow --timestamps wenotecloudstorage_flask_1
error from daemon in stream: Error grabbing logs: EOF

Is there an easy way, I can figure out the reason why a docker container keep restarting?

eLRuLL
  • 17,785
  • 8
  • 68
  • 96
Cheok Yan Cheng
  • 48,324
  • 124
  • 436
  • 828
  • I would say attach to the docker, that will give you information, and of course checking the logs of the docker. – eLRuLL Dec 14 '18 at 16:42
  • Do you mean doing `docker attach wenotecloudstorage_flask_1`? But, that still give me error `You cannot attach to a restarting container, wait until it is running` – Cheok Yan Cheng Dec 14 '18 at 16:45
  • you could stop the container, and they start it without detaching – eLRuLL Dec 14 '18 at 16:46
  • Do you mean first run `docker stop wenotecloudstorage_flask_1`, then followed by `docker start --attach wenotecloudstorage_flask_1`? As, after running `docker start --attach wenotecloudstorage_flask_1`, 0 output is shown in console and the container fall back to Restarting. – Cheok Yan Cheng Dec 14 '18 at 16:51
  • The docker daemon log might provide some insight as well. The location varies based on your system, https://stackoverflow.com/questions/30969435/where-is-the-docker-daemon-log – hellosri Dec 14 '18 at 17:38
  • 1
    If the main container process exits immediately (because of a startup configuration error; because you tried to launch a background process) that could in theory cause this; you might try running it without the `-d` option to get live logs. Seeing the actual `docker-compose.yml` might give some hints. – David Maze Dec 14 '18 at 18:10
  • 1
    @CheokYanCheng also make sure you are not passing the `restart` policy to the containers you run. – eLRuLL Dec 15 '18 at 16:56

1 Answers1

4

Don't use "docker logs". Use "docker-compose logs flask" to see the logs of that restarting containers. With your options:

docker-compose logs -f --tail=50 flask

The error you see is because the normal "docker logs" is trying to read the logs, but the container dies already. Docker-compose handles it better.

If it is not in the logs, well, then you will have to dig deeper in the configuration of your app. But my bet is that you will see a nice log message that will bring you to the right direction.

Moreno
  • 516
  • 2
  • 14