Updated answer:
It looks like i was wrong and it is not a bug. --ansi
is not for controlling colored outputs of containers but only for outputs generated by compose itself. For example the status lines of docker compose up -d
Detailed answer on GitHub: https://github.com/docker/compose/issues/10161#issuecomment-1377981816
Original answer:
I think you have indeed found a bug. I don’t exactly know how it should work since I have never needed it. I have never tried to use docker compose run when I needed colored output, but colors and pipe worked with docker-compose-v1
which is Docker Compose v1 on macOS. v1 has different parameters and different default behavior so I could not disable showing colors. At least not by using --ansi
I could use Docker Compose v2 with colors and pipe when I added -e TERM=xterm
to the run command, but this seems odd since I don’t know what --ansi
is for then.
I could find bug reports related to Docker Desktop for Windows, but I also tried in a virtual machine using only Docker CE and Docker Compose v2.14 and had the same result.