Is it possible to remove the service name in the log output of docker-compose up?
My logs are currently looking like this:
serviceA | log1
serviceB | log2
serviceB | log3
serviceA | log4
But I want them to look like this:
log1
log2
log3
log4
The documentation states, that you can configure the logging for services like this:
version: "3.7"
services:
some-service:
image: some-service
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
But I couldn't find any option to remove the service name from the logs when running docker-compose up.
As proposed by EchoMike444, I've tried the following command:
docker-compose up --no-color 2>&1 | sed 's/^[^ ]* | //'
with the following docker compose file:
version: "3"
services:
consumer:
image: debian:stretch-slim
command:
[
"bash",
"-c",
"while ( true ) ; do echo $$(date) $$( hostname ) ; sleep $$(( $$RANDOM %4 )) ; done ",
]
ideas:
image: debian:stretch-slim
restart: always
command:
[
"bash",
"-c",
"while ( true ) ; do echo $$(date) $$( hostname ) ; sleep $$(( $$RANDOM %4 )) ; done ",
]
The output looks like this
ideas_1 | Sun Oct 20 05:56:23 UTC 2019 99295bdcbf2c
ideas_1 | Sun Oct 20 05:56:25 UTC 2019 99295bdcbf2c
Sun Oct 20 05:56:25 UTC 2019 dd45c5900159
ideas_1 | Sun Oct 20 05:56:27 UTC 2019 99295bdcbf2c
ideas_1 | Sun Oct 20 05:56:27 UTC 2019 99295bdcbf2c
Sun Oct 20 05:56:27 UTC 2019 dd45c5900159
Sun Oct 20 05:56:29 UTC 2019 dd45c5900159
ideas_1 | Sun Oct 20 05:56:30 UTC 2019 99295bdcbf2c
So it is working for service consumer, but not for ideas.
It seems you can now, this PR was merged:
https://github.com/docker/compose/pull/7435
ex: docker-compose up --no-log-prefix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With