Asterisk writes huge amount of zeros into logs

I built and run Asterisk with the following Dockerfile:

RUN useradd -d /home/asterisk -m --uid 2000 asterisk

VOLUME /var/lib/asterisk

USER asterisk
WORKDIR /home/asterisk
RUN wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-22-current.tar.gz
RUN tar -xzf asterisk-22-current.tar.gz
WORKDIR /home/asterisk/asterisk-22.1.1
RUN ./configure --with-jansson-bundled
RUN make

USER root
WORKDIR /home/asterisk/asterisk-22.1.1
RUN make install && make config && make samples

CMD /usr/sbin/asterisk -vvvvvvvvgc

I started it in its default configuration and noticed that a huge amount of messages like this:

{"log":"\u0000\u0000\u0000\u0000\u0000 ... u0000\u0000\u0000\u0000","stream":"stdout","time":"2025-01-31T10:44:08.116965488Z"}

appear in the Docker’s JSON logs (not stdout). I can see them from the host machine with a command like

sudo tail -1 /var/lib/docker/containers/7cd6aa6bd4eab91867b0aad48ad3a84b589a0ad969f830009b959a69e6f8f8cb/7cd6aa6bd4eab91867b0aad48ad3a84b589a0ad969f830009b959a69e6f8f8cb-json.log

Where do they go from? What are they for?

If I run the container with the lowest verbosity level:

sudo docker run -d --rm --name asterisk --cpus=0.5 u24asterisk "/usr/sbin/asterisk -gc"

I got the same effect.

See my blog post for details and stdout logs.

Probably I found the solution here

The fix is indeed to disable Asterisk console mode (don’t use “-c” when running under docker, ever). I want to say this is an Asterisk bug, but even at 100% CPU use to keep up, Docker really should quash these duplicates somehow as well to avoid logging buffer explosion.

At least with the command

CMD /usr/sbin/asterisk -vvvvvvvvfp

there are no zeros in JSON logs anymore.