Docker Community Forums

Share and learn in the Docker community.

Control Characters in output from docker-compose on Jenkins


we use docker-compose to build and run some automated tests in Jenkins.

this is my script to do so:

docker-compose down --remove-orphans
docker-compose pull --include-deps
docker-compose build --pull $NOCACHE ci
docker-compose up --quiet-pull --abort-on-container-exit --force-recreate --always-recreate-deps --exit-code-from ci ci
{ exitCode=$?; } 2>/dev/null
docker-compose down --remove-orphans
exit $exitCode

and it works fine, but I do get these control characters in my output:

Stopping claim_db_1 …
Stopping claim_db_1 … e[32mdonee[0m

Then Jenkins interprets the colors and we are left with:

Stopping claim_db_1 …
Stopping claim_db_1

And this bugs me a lot!
I know how these control characters work in a terminal emulator.
I just need a way to tell docker-compose, that it does have a non-interactive interface to work with and stop this mess of arguably unreadable output.

I am ok with loosing color output.
I tried piping to cat, dosn’t work.
I tried unsetting TERM or setting it to dumb.
I tried a couple of other stuff, none of which worked.
I tried searching for a solution but can’t find any.

The closest I got is this:
docker-compose down 2> >(sed 's/\x1B\[[0-9][BAK]/\n/g' | sed '/^$/d' >&2)

Jenkins is in no way the only scenario here, just consider this:
docker-compose down 2>&1 | cat > test.txt

The entire issue with all it’s solutions and related infos can be found here: