D
D
dimansny2021-03-31 10:16:38
linux
dimansny, 2021-03-31 10:16:38

Docker logging to file with extra characters added?

Docker logs to the file, adding some extra obscure prefix and suffix to each message. What I do:
1. Run hello-world image

$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/


2. Let's look at the container logs:
$ cat /var/lib/docker/containers/719b733ae07d0bbc095b9828d67356ac9417b71401f7972f5270fc4bd6ad326a/local-logs/container.log

Displays such a crap
6064218a548f4013290428.png
Appeared from somewhere incomprehensible prefix stdout with non-printable characters at the beginning and the same garbage at the end. Can you tell me which way to dig? It also appears with other PS containers.

Ideally, I would like to remove these prefixes and suffixes, because they break the assembly of logs

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
chupasaurus, 2021-03-31
@chupasaurus

local logging driver

S
Sergey Sokolov, 2021-03-31
@sergiks

view logs: docker logs 302808df0b97
where is the hash of the container to look at startup or find out docker ps -a
It is better to give the container a name at startup:

docker run --name QnA hello-world

docker logs QnA

S
Saboteur, 2021-03-31
@saboteur_kiev

why do you think the docker log is a text file?
By default, this is a structured json log, and the prefix explicitly indicates the string is stdout or stderr, plus a timestamp.
To find out what is in the log, you should check the docker settings and find out what log driver you have (usually --log-driver json-file), then go to the documentation and read the details https://docs.docker.com/config/containers/ logging/...
it is possible to change the logging driver to local

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question