A Python utility that aggregates and displays logs from all running Docker containers in a single, color-coded terminal view.
- Multi-container log streaming: View logs from all running containers simultaneously
- Color-coded output: Each container gets a unique color for easy identification
- Real-time updates: Streams logs as they happen using Docker's log streaming API
- Multi-threaded: Efficiently handles multiple containers using Python threading
- Keyboard interrupt support: Clean exit with Ctrl+C
- Python 3.6 or higher
- Docker Engine running and accessible
- Docker daemon socket access (typically requires running with appropriate permissions)
- Clone this repository:
git clone https://github.com/emy3/docker-logs.git
cd docker-logs- Install the required Python dependencies:
pip install docker richAlternatively, you can create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install docker richSimply run the script:
python dockerLog.pyThe script will:
- Connect to your local Docker daemon
- List all currently running containers
- Start streaming logs from each container
- Display logs with color-coded container names
To stop the log stream, press Ctrl+C.
webapp: 127.0.0.1 - - [11/Oct/2025 13:30:45] "GET / HTTP/1.1" 200 -
database: 2025-10-11 13:30:46.123 UTC [1] LOG: database system is ready to accept connections
redis: 1:M 11 Oct 2025 13:30:47.456 * Ready to accept connections
webapp: 127.0.0.1 - - [11/Oct/2025 13:30:48] "GET /api/users HTTP/1.1" 200 -
Each container name is displayed in a unique color, making it easy to follow specific container logs in a busy environment.
- Docker Connection: Uses the Docker Python SDK to connect to the Docker daemon via environment variables
- Container Discovery: Lists all currently running containers
- Color Assignment: Assigns a random hex color to each container for visual distinction
- Threaded Streaming: Creates a separate thread for each container to stream logs independently
- Rich Console Output: Uses the
richlibrary for colored terminal output
If you encounter permission errors when connecting to Docker, ensure:
- Your user is in the
dockergroup:sudo usermod -aG docker $USER - Docker daemon is running:
sudo systemctl status docker - Log out and back in for group changes to take effect
The script only shows logs from currently running containers. Start some containers first:
docker run -d nginx
docker run -d redisInstall the required dependencies:
pip install docker richThis project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
Created by honeydu
- Docker SDK for Python - Docker API interaction
- Rich - Beautiful terminal formatting