How to view Docker container application logs

How to view Docker container application logs

docker attach command

docker attach [options] 容器will connect to the running container and then print out the container's standard input, output, and error stream information locally. There are three possible 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 enter the container using multiple windows at the same time, all windows will be displayed synchronously. If one window is blocked, other windows cannot be operated on.

You can use ctrl+c to disconnect directly, but this will cause the container to exit and stop . If you want the container to continue running when you detach from 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 the container's standard input and output, docker uses a memory buffer of approximately 1MB to maximize the throughput of your application. If this buffer fills up, the speed of output or writing will be affected. Therefore, to view the application logs, you can use the docker logs command.

docker logs command

docker logs [options] 容器Gets the container's logs.

For example, print the last 10 lines of the mytest application in the container.

$ docker logs --tail="10" mytest

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Implementation of modifying configuration files in Docker container
  • Implement dynamic management and monitoring of docker containers based on spring-boot and docker-java [with complete source code download]
  • Summary of methods for creating, listing, and deleting Docker containers on Linux
  • Detailed explanation of log processing of Docker containers
  • Detailed explanation of how to stop the Docker container from automatically exiting
  • Detailed explanation of how to solve the problem that the docker container cannot access the host machine through IP
  • How to use Docker container to access host network
  • Docker container operation instructions summary and detailed explanation

<<:  How to use http and WebSocket in CocosCreator

>>:  Several important MySQL variables

Recommend

A brief analysis of the basic concepts of HTML web pages

What is a web page? The page displayed after the ...

Blog Design Web Design Debut

The first web page I designed is as follows: I ha...

Play mp3 or flash player code on the web page

Copy code The code is as follows: <object id=&...

Understand CSS3 Grid layout in 10 minutes

Basic Introduction In the previous article, we in...

Steps for importing tens of millions of data into MySQL using .Net Core

Table of contents Preliminary preparation Impleme...

Loading animation implemented with CSS3

Achieve results Implementation Code <h1>123...

How to install and use Cockpit on CentOS 8/RHEL 8

Cockpit is a web-based server management tool ava...

Native js realizes the drag and drop of the nine-square grid

Use native JS to write a nine-square grid to achi...

Analysis of several reasons why Iframe should be used less

The following graph shows how time-consuming it is...

javascript implements web version of pinball game

The web pinball game implemented using javeScript...

Vue implements multi-column layout drag

This article shares the specific code of Vue to i...

Vue implements mobile phone verification code login

This article shares the specific code of Vue to i...

CSS achieves highly adaptive full screen

When writing my own demo, I want to use display:f...