How do you view logs for a container?

To view logs for running containers, we can use LOG command.

  > docker logs --follow

The --follow flag will continue streaming the new output from the container's STDOUT and STDERR onto the terminal.

What are restart policies?

docker restart policies dictate how a container should behave when it is shutted down by some factor.

There are four restart-policies:

  • No - Never restart when stopped by some means
  • Always - Always restart no matter how it is stopped
  • On-Failure - Restart only when the container stops with an erroneous code
  • Unless-Stopped - Restart always unless stopped manually with a KILL or STOP