You can view the container logs through the docker logs command. Command format:$ docker logs [OPTIONS] CONTAINER Options: --details Display more information -f, --follow Track real-time logs --since string Display logs after a certain timestamp, or relative time, such as 42m (i.e. 42 minutes) --tail string How many lines of log are displayed from the end of the log, the default is all -t, --timestamps Display timestamps --until string Display logs before a certain timestamp, or relative time, such as 42m (i.e. 42 minutes) example:View the logs after the specified time and only display the last 100 lines: $ docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID View the logs for the last 30 minutes: $ docker logs --since 30m CONTAINER_ID View the logs after a certain time: $ docker logs -t --since="2018-02-08T13:23:37" CONTAINER_ID View logs for a certain period of time: $ docker logs -t --since="2018-02-08T13:23:37" --until "2018-02-09T12:23:37" CONTAINER_ID Supplement: Debugging tips for Docker containers: docker logs and docker service logs Debugging containersMany students who are new to Docker often encounter problems with the Docker container not being able to start, or they keep starting it repeatedly without knowing what to do. Docker provides a series of simple commands that make it easy to debug problems in container operation. The principle is very simple, that is, you can directly output the logs of the container runtime (or past tense). There are usually 4 ways: The following will introduce Start the container from the consoleFor example, debug and start the redis container docker run -it -rm redis redis-server [redis startup parameters omitted...] In this way, the log output of redis-server is printed directly to the console The disadvantage is that this method is only used when starting container debugging, and cannot operate containers running in the background or expired containers. Docker exec attaches to the background container Sometimes you need to enter the container to check the system operation status. At this time, you can use docker exec. The premise of using docker exec is that the container is running. Therefore, when the container does not work properly, this command often cannot be used. docker logsIn fact, no matter what state the docker container is in, you can use docker logs to get all the logs of the container. docker logs [container name] Docker logs also has limitations, that is, it is not possible to obtain container logs that failed to start in Docker swarm mode. docker service logsFor Docker swarm mode, get the command for container logs. Generally, execute the following commands in sequence to get the container name of a service docker service ls docker service ps [service name] Then you can get its log by container name docker service logs [container name] Docker service logs shows that the log is emptyTo make docker service logs work properly, you need to set some docker configuration vi /etc/docker/daemon.json Add to this file: { "log-driver": "json-file", "log-opts": { "labels": "production_status,geo", "env": "os,customer" } } Then restart docker service docker restart For a detailed introduction to docker service logs, please refer to the official documentation The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: Specific use of CSS content attribute
>>: React component communication routing parameter transfer (react-router-dom)
Monitoring method in Vue watch Notice Name: You s...
1. When the mobile terminal processes the list sl...
This article uses examples to explain the basic k...
How to create a Linux virtual machine in VMware a...
Many people also asked me what books I read when ...
1. Paradigm The English name of the paradigm is N...
Table of contents Business Logic Data table struc...
This article shares the installation tutorial of ...
This article introduces some issues about HTML ta...
1. Why set maxPostSize? The tomcat container has ...
[ Linux installation of Tomcat8 ] Uninstall Tomca...
This article shares the installation and configur...
Table of contents 1. Introduction 2. MVCC (Multi-...
1. What is a transaction? A database transaction ...
This article describes MySQL index coverage with ...