How to troubleshoot Docker Server(daemon) and Containers?

How to troubleshoot Docker Server(daemon) and Containers?

There are following way using troubleshooting of Docker Server and Containers can be done. If you are running your container in -d (detached mode) or by docker remote API, you will not see any logs in console. To access running docker image or container logs you need to use docker logs command.

Docker Containers Logs

The docker logs command shows information logged by a running container.

[code]$ docker logs cont-id
$ docker container logs cont-id
$ docker logs –details CONTAINER
$ docker logs [OPTIONS] CONTAINER
$ docker container logs [OPTIONS] CONTAINER
$ docker help logs
# To follow docker log output or tail continuously
$ docker logs –follow ContainerName/ContainerID

# To see last n lines of logs
$ docker logs –tail 2500 ContainerName/ContainerID

# To see logs since particular date or timestamp
$ docker logs –since 2017-05-03 ContainerName/ContainerID[/code]

The docker service logs command shows information logged by all containers participating in a service.

[code]$ docker service logs[/code]

  • If you use a logging driver which sends logs to a file, an external host, a database, or another logging back-end, docker logs may not show useful information.
  • If your image runs a non-interactive process such as a web server or a database, that application may send its output to log files instead of STDOUT and STDERR.

Docker Events from Docker Server

To get real time events from the server, we can docker events commands. Information can include historical information and real-time information.

[code]$ docker events[/code]

Docker containers will report the following events:
attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update

Docker images report the following events:
delete, import, load, pull, push, save, tag, untag

Docker volumes report the following events:
create, mount, unmount, destroy

Docker networks report the following events:
create, connect, disconnect, destroy

Docker Daemon Logs

Docker daemon log depends on your OS. Here are the few locations, with commands for few Operating Systems:

  • Ubuntu (old using upstart ) – /var/log/upstart/docker.log
  • Ubuntu (new using systemd ) – sudo journalctl -fu docker.service
  • Boot2Docker – /var/log/docker.log
  • Debian GNU/Linux – /var/log/daemon.log
  • CentOS – /var/log/daemon.log | grep docker
  • CoreOS – journalctl -u docker.service
  • Fedora – journalctl -u docker.service
  • Red Hat Enterprise Linux Server – /var/log/messages | grep docker
  • OpenSuSE – journalctl -u docker.service
  • OSX – ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log/d‌​ocker.log
  • Windows – Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5) | Sort-Object Time

If your OS is using systemd then you can view docker daemon log with:
$ sudo journalctl -fu docker.service

Using CentOS7, logs are available using the command
$ journalctl -u docker

For Docker Mac Native (without Boot2Docker or docker-machine, running your Docker installation without extra VirtualBox
$ syslog -k Sender Docker

Docker for Mac (Beta)

Rajesh Kumar

DevOps Architect - Mentor - Coach - Trainer at Cotocus
Email -
CV -

Total, Over 15 years of extensive experience working with more than 8 software MNCs for software development/maintenance and production environments involved in continuous improvement and automating entire life cycle using latest devops tools and techniques from design and architecture, through implementation, deployment, and successful operations. Also, helping more than 70 software organizations globally, providing coaching, mentoring and consulting in devops, CICD, cloud, containers and operations.

I help software organization to improve a quality of the software, reducing the software development/operational cost and immediate feedback/monitoring. Have in-depth working experience in following domains with real project implementation.

- Test Driven DevOps Approach
- Continuous Integration
- Continuous Delivery
- Continuous Deployment
- Continuous Inspection
- Technical Debt Reduction
- Containerization/Micro Services Using Kubernetes & Docker
- Cloud Migration using AWS
- Production Monitoring & Postmortem
Rajesh Kumar