Introduction
Docker has revolutionized the way we deploy applications, making it easy to run numerous services on a single host. However, keeping track of which services are running on which ports can become challenging, especially when multiple services default to the same port. This can lead to security risks and accessibility issues.
“whatsrunning” is a tool designed to address this problem by providing a clear overview of all exposed TCP ports on your Docker containers. It automatically detects new services, creating a simple form of service discovery that requires zero configuration. This guide will walk you through the installation and usage of “whatsrunning,” ensuring you can effectively manage your Docker services and enhance your container security.
Installation Instructions
To get started with “whatsrunning,” follow these detailed installation instructions. This guide assumes you have Docker installed on your system. If not, please install Docker first by following the official Docker installation guide.
Prerequisites
- A system with Docker installed (Ubuntu, CentOS, etc.)
- Access to the internet to pull Docker images
- Basic knowledge of Docker commands
Step-by-Step Installation
- Open a terminal on your Docker host machine.
- Run the following command to start the “whatsrunning” container:
docker run --rm -d -p 80:5000 -v /var/run/docker.sock:/var/run/docker.sock -e HOST_HOSTNAME=$(hostname -f) mikeage/whatsrunning:latest
This command does the following:
- –rm: Automatically removes the container when it exits.
- -d: Runs the container in detached mode.
- -p 80:5000: Maps port 80 on the host to port 5000 on the container.
- -v /var/run/docker.sock:/var/run/docker.sock: Mounts the Docker socket to allow the container to communicate with the Docker daemon.
- -e HOST_HOSTNAME=$(hostname -f): Sets the environment variable HOST_HOSTNAME to the full hostname of the host.
- mikeage/whatsrunning:latest: Specifies the Docker image to use.
- Verify the container is running by executing:
docker ps
You should see the “whatsrunning” container listed. If not, check the Docker logs for any errors:
docker logs [container_id]
- Access the “whatsrunning” dashboard by navigating to http://localhost in your web browser. If you are running Docker on a remote server, replace localhost with the server’s IP address.
Main Content Sections
Using “whatsrunning” for Service Discovery
Once installed, “whatsrunning” automatically detects and displays all exposed TCP ports of running Docker containers. The main dashboard provides links to these services, making it easy to access them without remembering specific port numbers.
Core Features and Configurations
- Zero Configuration: “whatsrunning” requires no configuration, making it easy to set up and use.
- Automatic Service Detection: New services are automatically detected and displayed on the dashboard.
- Lightweight: The container uses less than 75MB of disk space and 50MB of RAM.
- Secure: By monitoring exposed ports, you can quickly identify and mitigate potential security risks.
Practical Examples or Case Studies
Example: Monitoring a Flask Application
Suppose you have a Flask application running in a Docker container. By default, Flask listens on port 5000, which can conflict with other services. Here’s how “whatsrunning” can help:
- Run your Flask application in a Docker container:
docker run -d -p 5000:5000 myflaskapp
- Navigate to the “whatsrunning” dashboard. You will see an entry for your Flask application, with a link to access it.
- Click the link to open your Flask application in a web browser.
This simple example demonstrates how “whatsrunning” can streamline service discovery and management, especially when dealing with multiple Docker containers.
Tips, Warnings, and Best Practices
- Security Best Practices: Regularly monitor the “whatsrunning” dashboard to identify unexpected open ports, which could indicate potential security vulnerabilities.
- Performance Optimization: Keep your Docker environment clean by removing unused containers and images to ensure optimal performance of “whatsrunning.”
- Avoid Common Pitfalls: Ensure the Docker socket is correctly mounted to avoid communication issues between “whatsrunning” and the Docker daemon.
Conclusion
“whatsrunning” is a valuable tool for anyone managing multiple Docker containers, providing a simple and effective way to monitor exposed TCP ports and enhance container security. Its zero-configuration setup and automatic service detection make it an easy addition to any self-hosted environment. By using “whatsrunning,” you can streamline service discovery, improve security, and simplify Docker container management.
Additional Resources
- Docker Official Documentation – Comprehensive guide to Docker installation and usage.
- whatsrunning GitHub Repository – Source code and detailed documentation for “whatsrunning.”
- whatsrunning Screenshots – Visual examples of the “whatsrunning” dashboard.
Frequently Asked Questions (FAQs)
- Q: What are the system requirements for running “whatsrunning”?
A: “whatsrunning” requires Docker to be installed on a Linux-based system. It uses less than 75MB of disk space and 50MB of RAM.
- Q: Can I change the default port for “whatsrunning”?
A: Yes, you can change the port mapping in the Docker run command. For example, to use port 8080, run
docker run --rm -d -p 8080:5000 -v /var/run/docker.sock:/var/run/docker.sock -e HOST_HOSTNAME=$(hostname -f) mikeage/whatsrunning:latest
. - Q: Does “whatsrunning” support HTTPS?
A: By default, “whatsrunning” uses HTTP. However, you can use a reverse proxy like Nginx or Traefik to add HTTPS support.
Troubleshooting Guide
Common Issues and Solutions
- Issue: “whatsrunning” container fails to start.
Solution: Check Docker logs for errors using
docker logs [container_id]
. Ensure the Docker socket is correctly mounted and the port is not in use by another service. - Issue: Services not appearing on the “whatsrunning” dashboard.
Solution: Verify the services are running and have exposed TCP ports. Restart the “whatsrunning” container if necessary.
By following this guide, you should be able to successfully install and use “whatsrunning” to enhance your Docker container management and security. For further assistance, refer to the additional resources and FAQs provided.