Home  >  Article  >  Operation and Maintenance  >  How to view docker running logs

How to view docker running logs

尚
Original
2020-03-23 11:04:3710268browse

How to view docker running logs

Introduction to the method of viewing docker running logs:

docker attach command

docker attach [options] The container will be connected to The running container, and then print out 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 only 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 windows will be displayed simultaneously. If one window is blocked, other windows will no longer be able to operate.

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

$ docker attach --sig-proxy=false mytest

Note: When using docker attach to connect to a container's standard input and output, docker uses a memory buffer of approximately 1MB to maximize application throughput. If this buffer fills up, the speed of output or writing will be affected. Therefore, to view application logs, you can use the docker logs command.

docker logs command

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

How to view docker running logs

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

$ docker logs --tail="10" mytest

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How to view docker running logs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn