![Docker Tutorial](/docker/images/docker-mini-logo.jpg)
- Docker Tutorial
- Docker - Home
- Docker - Overview
- Docker - Installing Docker on Linux
- Docker - Installation
- Docker - Hub
- Docker - Images
- Docker - Containers
- Docker - Working With Containers
- Docker - Architecture
- Docker - Container & Hosts
- Docker - Configuring
- Docker - Containers & Shells
- Docker - File
- Docker - Building Files
- Docker - Public Repositories
- Docker - Managing Ports
- Docker - Private Registries
- Building a Web Server Docker File
- Docker - Instruction Commands
- Docker - Container Linking
- Docker - Storage
- Docker - Networking
- Docker - Setting Node.js
- Docker - Setting MongoDB
- Docker - Setting NGINX
- Docker - Toolbox
- Docker - Setting ASP.Net
- Docker - Cloud
- Docker - Logging
- Docker - Compose
- Docker - Continuous Integration
- Docker - Kubernetes Architecture
- Docker - Working of Kubernetes
- Docker Useful Resources
- Docker - Quick Guide
- Docker - Useful Resources
- Docker - Discussion
Docker - Logging
Docker has logging mechanisms in place which can be used to debug issues as and when they occur. There is logging at the daemon level and at the container level. Let’s look at the different levels of logging.
Daemon Logging
At the daemon logging level, there are four levels of logging available −
Debug − It details all the possible information handled by the daemon process.
Info − It details all the errors + Information handled by the daemon process.
Errors − It details all the errors handled by the daemon process.
Fatal − It only details all the fatal errors handled by the daemon process.
Go through the following steps to learn how to enable logging.
Step 1 − First, we need to stop the docker daemon process, if it is already running. It can be done using the following command −
sudo service docker stop
![Docker Daemon Process](/docker/images/docker_daemon_process.jpg)
Step 2 − Now we need to start the docker daemon process. But this time, we need to append the –l parameter to specify the logging option. So let’s issue the following command when starting the docker daemon process.
sudo dockerd –l debug &
The following points need to be noted about the above command −
dockerd is the executable for the docker daemon process.
The –l option is used to specify the logging level. In our case, we are putting this as debug
& is used to come back to the command prompt after the logging has been enabled.
![Points](/docker/images/points.jpg)
Once you start the Docker process with logging, you will also now see the Debug Logs being sent to the console.
![Debug Logs](/docker/images/debug_logs.jpg)
Now, if you execute any Docker command such as docker images, the Debug information will also be sent to the console.
![Docker Images Logging](/docker/images/docker_images_logging.jpg)
Container Logging
Logging is also available at the container level. So in our example, let’s spin up an Ubuntu container first. We can do it by using the following command.
sudo docker run –it ubuntu /bin/bash
![Container Logging](/docker/images/container_logging.jpg)
Now, we can use the docker log command to see the logs of the container.
Syntax
Docker logs containerID
Parameters
containerID − This is the ID of the container for which you need to see the logs.
Example
On our Docker Host, let’s issue the following command. Before that, you can issue some commands whilst in the container.
sudo docker logs 6bfb1271fcdd
Output
![Container Logging Output](/docker/images/container_logging_output.jpg)
From the output, you can see that the commands executed in the container are shown in the logs.
To Continue Learning Please Login