Get the App
SLTechnology News&Howtos  ›  Development  › 

How to view the Docker container application log

Shulou Source: shulou.com Published: 2022-06-01 03:43:36 11月12日 Update

Most people do not understand the knowledge of this article "how to view the Docker container application log", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to view the Docker container application log" article.

Docker attach command

The docker attach [options] container connects to the running container and prints the container's standard input, output, and error stream information locally. There are three values for options in the command:-- detach-keys,--no-stdin,--sig-proxy.

This command just enters the container terminal and does not start a new process. So when you use multiple windows to enter the container at the same time, all the windows will be displayed synchronously. If one window is blocked, the other windows can no longer operate.

You can disconnect directly with ctrl+c, but this will cause the container to exit and become stop. If you want to leave the container terminal, the container is still running. You need to use the-- sig-proxy parameter. For example:

$docker attach-sig-proxy=false mytest

Note: when using docker attach to connect to the container's standard input and output, docker uses a memory buffer of about 1mb to maximize the throughput of the application. If this buffer fills up, the speed of output or write will be affected. So to view the application log, you can use the docker logs command.

Docker logs command

The docker logs [options] container gets the log of the container.

For example, print the contents of 10 lines after the container mytest is applied.

$docker logs-tail= "10" mytest above is about the article "how to view the Docker container application log". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please follow the industry information channel.

Tags: Container application content log command output article standard knowledge article terminal buffer buffer input run maximum value information memory parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB macOS Microsoft NVidia