Remove ANSI escape sequences from logs

The output for command docker logs is sometimes formatted using ANSI escape sequences, even when it is redirected to a pipe or a file. The biggest problem is forced line wrapping — the keywords are broken in two and search doesn’t find them.

Searching online I found that it was a common problem several years ago. There were special command line and configuration options to “disable formatting”, “disable color”, “disable ansi”, “force raw” and so on. But then the problems got fixed, and those options I found no longer work in the latest version.

How do I disable ANSI formatting of docker logs output?

Update: This was observed for running docker logs under Jenkins. The problem stopped reproducing after the latest (2020-02-19) update.