Docker Logging: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 11: Zeile 11:
 
*Containerprotokolle anzeigen:
 
*Containerprotokolle anzeigen:
 
  docker logs nginx
 
  docker logs nginx
 +
<pre>
 +
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
 +
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
 +
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
 +
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
 +
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
 +
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
 +
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
 +
/docker-entrypoint.sh: Configuration complete; ready for start up
 +
2023/02/13 07:11:47 [notice] 1#1: using the "epoll" event method
 +
2023/02/13 07:11:47 [notice] 1#1: nginx/1.23.3
 +
2023/02/13 07:11:47 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
 +
2023/02/13 07:11:47 [notice] 1#1: OS: Linux 5.4.0-137-generic
 +
2023/02/13 07:11:47 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
 +
2023/02/13 07:11:47 [notice] 1#1: start worker processes
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 29
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 30
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 31
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 32
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 33
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 34
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 35
 +
2023/02/13 07:11:47 [notice] 1#1: start worker process 36
 +
 +
</pre>
 
*Nur neue Protokolle anzeigen:  
 
*Nur neue Protokolle anzeigen:  
 
  docker logs -f nginx
 
  docker logs -f nginx

Version vom 13. Februar 2023, 07:23 Uhr

Standart Syntax

  • Der Standart Syntax sieht wie folgt aus.
docker inspect [OPTIONS] NAME
  • Standardmäßig verwendet Docker einen JSON-Protokolltreiber, der Protokolle im JSON-Format in eine containerspezifische Datei auf dem Host schreibt, auf dem der Container ausgeführt wird.

Was ist ein Protokolltreiber?

  • Protokollierungstreiber sind Mechanismen von Docker zum Sammeln von Daten aus laufenden Containern und Diensten.
  • Immer wenn ein neuer Container erstellt wird, stellt Docker automatisch den JSON-Datei-Protokolltreiber bereit, wenn keine andere Protokolltreiberoption angegeben wurde.


Beispiel fürs anzeigen verschiedener Docker Informationen

  • Containerprotokolle anzeigen:
docker logs nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/02/13 07:11:47 [notice] 1#1: using the "epoll" event method
2023/02/13 07:11:47 [notice] 1#1: nginx/1.23.3
2023/02/13 07:11:47 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2023/02/13 07:11:47 [notice] 1#1: OS: Linux 5.4.0-137-generic
2023/02/13 07:11:47 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/02/13 07:11:47 [notice] 1#1: start worker processes
2023/02/13 07:11:47 [notice] 1#1: start worker process 29
2023/02/13 07:11:47 [notice] 1#1: start worker process 30
2023/02/13 07:11:47 [notice] 1#1: start worker process 31
2023/02/13 07:11:47 [notice] 1#1: start worker process 32
2023/02/13 07:11:47 [notice] 1#1: start worker process 33
2023/02/13 07:11:47 [notice] 1#1: start worker process 34
2023/02/13 07:11:47 [notice] 1#1: start worker process 35
2023/02/13 07:11:47 [notice] 1#1: start worker process 36

  • Nur neue Protokolle anzeigen:
docker logs -f nginx
  • CPU- und Speicherauslastung anzeigen:
docker stats
  • CPU- und Speicherauslastung für bestimmte Container anzeigen:
docker stats nginx
  • Laufende Prozesse in einem Container anzeigen:
docker top nginx