brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker compose logs --no-log-prefix prints plain log lines

Docker
~/tips/tip-compose-logs-no-log-prefix

docker compose logs --no-log-prefix --no-color --tail 100 app

Prints compose logs without the service-name prefix, so the lines can be copied cleanly.

Compose puts the service name and a bar in front of every log line. That is useful until you want to copy a stack trace or pipe the output somewhere.

The option leaves the prefix out. The same page lists --no-color for monochrome output, -t or --timestamps to show timestamps, and -n or --tail for the number of lines from the end of each container’s logs, which defaults to all.

docker compose logs --no-log-prefix --no-color --tail 100 app

That prints the last hundred lines of the app service without the name and without colour codes, so you can paste it into an issue or a message without cleaning it up first. For something to search through, send it to a file or to grep:

docker compose logs --no-log-prefix --no-color --timestamps app | grep -i error

Without the prefix you can no longer see which container a line came from, so only use it with a single service name, or add --timestamps if you must mix several and want some order. There is also an --until option that shows logs before a timestamp or a relative time such as 42m, which helps when you look for one moment in the past.

Further reading: docker compose logs

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link