`docker compose build` output is not updated properly in the console

When I run docker compose build, the output in the console is not being updated properly: some of the lines are updated in place (as they should be), but some are appended to the end of the output, see the video.

I tried searching the forum, the closest match seems to be this thread, but it’s not 100% the same.

It used to work properly before with the same setup, the problems started after some Docker update a few weeks, maybe 2-3 months ago.
For now, I’m using docker compose build --progress=plain as a workaround, but still, would be nice to have it working properly again.

Docker compose version:

$ docker compose version 
Docker Compose version v2.17.3

Docker version:

$ docker version 
Client: Docker Engine - Community
 Version:           23.0.5
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        bc4487a
 Built:             Wed Apr 26 16:17:30 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
  Version:          23.0.5
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       94d3ad6
  Built:            Wed Apr 26 16:17:30 2023
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
  Version:          0.19.0
  GitCommit:        de40ad0

OS version (Ubuntu MATE):

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

Terminal version: MATE Terminal, 1.24.0.


$ docker context show

$ docker info
 Context:    default
 Debug Mode: false
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

 Containers: 24
  Running: 0
  Paused: 0
  Stopped: 24
 Images: 67
 Server Version: 23.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
   Profile: builtin
 Kernel Version: 5.4.0-148-generic
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 13.59GiB
 Name: MATEPC3
 Docker Root Dir: /home/user/docker_stuff
 Debug Mode: false
 Username: egor83
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
 Live Restore Enabled: false

WARNING: No swap limit support