This bash script will do what you want:
Docker magazines
#!/bin/bash if [ $# -eq 0 ]; then echo "Usage: $(basename "$0") containerid ..." exit 1 fi pids=() cleanup() { kill "${pids[@]}" } trap cleanup EXIT while [ $# -ne 0 ] do (docker logs -f -t --tail=10 "$1"|sed -e "s/^/$1: /")& pids+=($!) shift done wait
Using:
$ docker-logs containerid1 containerid2 ... containeridN
The output from this script contains each line of monitored logs with the addition of a container identifier.
The script runs in --follow mode and should be interrupted using Ctrl-C .
Please note that docker logs parameters are hardcoded in the script. If you need to be able to manage docker logs parameters from the command line, then you will need to parse the command line arguments (for example, using getopts ).
source share