How to get `docker logs` to localize timestamp?

How to get localized timestamps when using docker logs? Is that possible?

root@server:~# date
Fri Oct 18 10:13:56 AM CEST 2024
           ^^          ^

root@server:~# docker logs -f --timestamps --since 5m apache
2024-10-18T08:12:28.384311702Z 172.18.0.6 - - [18/Oct/2024:08:12:28 +0000] "GET /download/1b0e44b7-39c5-4dc2-a1c2-d8bf1123488e.data HTTP/1.1" 200 68528
           ^^                ^

Sync the container’s time to your host machine:

services:
  service:
    ...
    volumes:
      - /etc/localtime:/etc/localtime:ro

I don’t think there is a builtin way. Mounting the localtime file could affect only the process in the container. You could try using awk like this

docker logs httpd --timestamps 2>/dev/stdout \
  | awk '{ "date -d \"" $1 "\"" | getline localtime; $1=localtime; print }'

“getline” is for executing a command in a subshell and storing the result in a variable. “localtime” in this case. Then $1=localtime overrides the first column in the output so print can show the modified log line.

The only problem is that you need to redirect the error stream to the standard output. Otherwise error messages would not be read by awk (or any process in the pipe). So if you want to separate the streams, you would need to write a more complicated solution