Docker Community Forums

Share and learn in the Docker community.

Remove leading container name from docker-compose logs

docker

(Scarlson) #1

How can I remove the leading service names from the docker-compose output logging?
When running docker-compose up I get logs such as

container_1 | container output text
container_1 | container output text

I would like

container output text
container output text

Is there a way to remove the leading container_1 |? I understand from a high level this is because if you have multiple containers this allows to discern which container is outputting the log as in

container_1 | container output text
container_2 | container output text

I know I can do start the services then attach to one like

docker-compose -d up
docker attach

but exiting on the docker-compose exit status becomes difficult and its a hack at best.

so,
How can I remove the leading service names from the docker-compose output logging

thanks!


(Scarlson) #2

bump for help. is this even possible?


(Scarlson) #3

Still working on this… so far nothing I have come up with works.

my thoughts are something along the line of:

   docker-compose up --abort-on-container-exit service & > /dev/null
   pid=$!
   docker logs -f ${BUILD_TAG}${SERVICE_LIST} &
   wait $pid

but of course the first command does not work. I cannot get any of the other logging drivers to do what I want either.

I’m really looking for any help here, I am incredibly surprised this is so difficult, but that may just be it and why I cannot find a simple solution.


(Scarlson) #4

Turns out I may have been overthinking it or missed something.

docker-compose up -d service
docker attach

should do what I want. i’ll confirm later.