Debugging in containerized environments

Nick

November 4, 2019

Debugging in containerized environments

DEBUGGING IN CONTAINERIZED ENVIRONMENTS

 Containerization is a lightweight form of machine virtualization that has to do with encapsulating an application and all its dependencies in a container with its operating environment.

 This technology is fast evolving, providing tremendous benefits for development teams, and leveraging on system infrastructure for optimal software performance 

 Is it safe to debug in containerized environments?

Debugging in a containerized environment is entirely safe with few exceptions in production environments. With production environments, debugging has to be carefully done with very high precision.

 How to debug in containerized environments

With many container programs logging information out to stdout, a first debugging option after creating a workspace for the application code will be to view the stdout history with the logs command, from here you can detect what the issue might be. The next step will be to stream stdout with the attach command this displays the content of the stdout in real-time. 


Another option will be to override the ENTRYPOINT of the image files in the containers. You could also try pausing and unpausing your container to see if this fixes your problem. You could also view container details with the inspect command. The inspect command returns container image or information with more information about the container such as the current state of the container, values of set environment, mapped ports, and paths to the log history file, etc. as a form of debug, you could also view image layers with the history command; this option is more of a build time diagnostic solution. 


Another handy debug method is to execute arbitrary commands with the exec tool which enables you to run arbitrary test commands inside a running container.

 Recommendations for Operating in Containerized environments

1. Put one container per application instead of combining several applications into one large container.

2. Ensure proper container startup

3. Check the container log

4. Have a good debugging tool which will deliver deep insights into your code


Nick

Nick

Nick is our Marketing Owner and works from our UK office, he has a wealth of experience in digital & data marketing and is a Certified Scrum Product Owner.