Logging mechanism in Docker

Last updated on May 27 2022
Raigiri Patil

Table of Contents

Logging mechanism in Docker

Docker – Logging

Docker has logging mechanisms in place which can be employed 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 subsequent 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 subsequent command −

sudo service docker stop

Page 1 Image 1 61
docker daemon process

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 subsequent command when starting the docker daemon process.

sudo dockerd –l debug &

The subsequent points need to be noted about the above command −

  • dockerd is the executable for the docker daemon process.
  • The –l option is employed to specify the logging level. In our case, we are putting this as debug
  • & is employed to come back to the command prompt after the logging has been enabled.
Page 1 Image 2 6
start

Once you start the Docker process with logging, you’ll also now see the Debug Logs being sent to the console.

Page 2 Image 3 29
Debug Logs

Now, if you execute any Docker command such as docker images, the Debug information will also be sent to the console.

Page 2 Image 4 9
docker images

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 subsequent command.

sudo docker run –it ubuntu /bin/bash

Page 3 Image 5 22
docker run

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 subsequent command. Before that, you can issue some commands whilst in the container.

sudo docker logs 6bfb1271fcdd

Output

Page 3 Image 6 11
docker logs

From the output, you can see that the commands executed in the container are shown in the logs.

 

So, this brings us to the end of blog. This Tecklearn ‘Logging mechanism in Docker ’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Docker and build a career in DevOps domain, then check out our interactive, Containerization using Docker Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/containerization-using-docker/

Containerization using Docker Training

About the Course

Tecklearn has specially designed this Containerization using Docker Training Course to advance your skills for a successful career in this domain. his Docker training online course will help you learn Docker containerization, running Docker containers, Docker image creation, Dockerfile, Docker orchestration, security best practices and more through hands-on projects and case studies. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Docker.

Why Should you take Containerization using Docker Training?

  • Average salary of Docker Expert is $110k – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.
  • Intuit, PayPal, Splunk, Uber & many other MNC’s worldwide use Docker across industries

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Containerization using Docker – Part 1

  • Introduction to Docker
  • Understanding Docker Lifecycle
  • Docker Architecture
  • Components of Docker Ecosystem
  • Common Docker Operations
  • Committing changes in a Container
  • Hands On

Containerization using Docker – Part 2

  • Building Custom Docker Images
  • Docker Image
  • Introduction to Docker Swarm
  • Deploying a 2-Node Cluster using Docker Swarm
  • Hands on

 

0 responses on "Logging mechanism in Docker"

Leave a Message

Your email address will not be published. Required fields are marked *