Select Page

Docker container logs for quick troubleshooting

Docker container logs for quick troubleshooting

Docker enables easy deployment of applications inside containers and this makes it popular in hosting and development businesses. But proper management of the Docker system is essential to reap the benefits of this infrastructure setup.

A Docker container that always crashes, a host machine that doesn’t have enough space, an application that throws up errors – all these issues can cripple the effectiveness of using a Docker system for your business.

Relevance of logs in Docker management

A efficient Docker management service involves a wide range of activities – creating new containers, resource control, performance monitoring, error debugging, automating tasks, backup management, and so on.

Examining the log files is vital in troubleshooting errors and issues during Docker management. A typical Docker setup consists of multiple containers, each with a log file associated with it.

These log files store all the relevant information and updates related to that container. When a container crashes often or the application running in it gives out random errors, these logs shed some light into what’s actually the cause.

In addition to container logs, there are service logs and host machine logs. Today, we’ll see how to access these various logs in a Docker system.

[ Use your time to build your business. We’ll take care of your customers. Hire Our Hosting Support Specialists at $9.99/hr. ]

How to access Docker container logs

To investigate the issues related to a Docker container, the container logs are useful. The logs associated with each container can be reviewed using these simple steps:

1. Connect to the Docker machine

Access the host machine in which the Docker containers are hosted, from the shell. You can use the ‘ssh’ tool from the command line interface to do that.

2. Identify the container ID

First we need to identify the container for which the logs are to be checked. You can list the whole containers in the machine using ‘docker ps’ command.

Choose the container ID of the one you need to check, from the list. The container ID associated with the application name (eg: WordPress), can be looked upon easily in this list.

 

docker container logs list

List docker containers

Suppose we need to examine the logs for the WordPress container. We can see that the container ID is ‘679facd4ee38’, from this list.

3. Examine the container logs

To view the logs for the WordPress container, use the command ‘docker logs [ID]’ where [ID] is the container ID.

 

examine docker container logs

Examine the logs for the selected container

 

Every Docker container has a folder “/var/lib/docker/containers/container-id” in the host machine, which contains the log file ‘container-id-json.log’. ‘json.log‘ is the default logging setup and it contains all the updates and access details to that container.

The contents of this log file are displayed using ‘docker logs’ command. The path to this container log file can be identified using the command ‘docker inspect [ID]‘ where [ID] is the container ID.

 

docker container logs path

Obtain the Log path for the container

 

Any information or message that is displayed to the container’s standard output/error will be logged in this json.log file, which can be retrieved using ‘docker logs‘ command.

 

docker container log json file

json log for the container

 

4. Investigate the Docker container logs

Memory errors, resource shortages, kernel problems, malicious attempts, attacks, etc. can be detected and investigated with the help of container logs.

Certain applications have their own extended log files, which are helpful in identifying and debugging the application related errors. Once the cause of the errors are identified, it is easy to fix them without delay.

[ You don’t have to lose your sleep to keep your customers happy. Our Hosting Support Specialists cover your servers and support your customers 24/7 at just $9.99/hour. ]


STOP SPENDING TIME ON SUPPORT!

Do you spend all day answering technical support queries?

Wish you had more time to focus on your business? Let us help you.

We free up your time by taking care of your customers and servers. Our engineers monitor your servers 24/7, and support your customers over help desk, live chat and phone.

HIRE SUPPORT SPECIALISTS AT $9.99/HR

Bobcares provides Outsourced Web Hosting Support and Outsourced Server Management for online businesses. Our services include 24/7 server support, help desk support, live chat support and phone support.

Submit a Comment

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

Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES