> ## Content Index
> Fetch the complete content index at: https://brianchristner.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to monitor Docker for Mac/Windows
- URL: https://brianchristner.io/how-to-monitor-docker-for-mac-windows/
- Published: 2017-07-12T05:50:00.000Z
- Updated: 2024-08-13T19:22:12.000Z
- Description: Learn how to monitor Docker on Mac and Windows using tools like Docker Dashboard and command-line utilities. Discover best practices for tracking performance metrics, identifying high resource usage, and maintaining a healthy Docker environment.
- Author: Brian Christner
- Tags: Docker

Monitoring is now baked into Docker for Mac/Windows by default. How cool is that? 

> We no longer need to guess about the performance of our development machines or test environments.

Some may ask the million-dollar question of why we would want to monitor our local installation.

Well, for starters, I am sort of monitoring mad and [monitoring everything](https://brianchristner.io/how-to-setup-prometheus-docker-monitoring/). Second, in order to truly understand your environment, we need to dissect what is running and how it's running. Finally, it is good practice to understand your environment and whether it is impacting the performance of your workload.

### Monitoring the Docker for Mac/Windows Daemon

Let's get started by configuring your installation. The following screenshots are from a Mac, but the steps should work the same for Windows. 

We will now enable [Daemon metrics](https://docs.docker.com/engine/reference/commandline/dockerd/?ref=brianchristner.io#daemon-metrics) on our Docker for Mac/Windows formatted for [Prometheus](https://prometheus.io/?ref=brianchristner.io)

1. Open Docker for Mac/Windows Preferences menu

![Docker Preferences](https://storage.ghost.io/c/29/50/2950930d-60f2-422c-90aa-232fbd4873b6/content/images/2017/07/docker-preferences.png)

2\. Navigate to the `Daemon` menu and click `Advanced`code box

![Docker Daemon](https://storage.ghost.io/c/29/50/2950930d-60f2-422c-90aa-232fbd4873b6/content/images/2017/07/docker-daemon.png)

3\. Inside the code box, we will add a line to enable the metrics. Add the following line of code below the \`debug\` statement: `metrics-addr" : "0.0.0.0:9323",` 

Click `Apply & Restart` and wait for Docker to come back online. 5\. Test it out. Open a browser tab with the following URL: `http://127.0.0.1:9323/metrics`a 

### Monitor with Prometheus

Our local Docker for Mac/Windows installation is now creating Prometheus formatted metrics. Next, let's start up a Prometheus stack and consume these newly created metrics.

1. Clone the Prometheus stack locally: `git clone https://github.com/vegasbrianc/prometheus.git .`
2. Edit the `prometheus/prometheus.yml` file. Navigate to the end of the file and find the section name. `static_configs`
3. Edit the target string with the hostname or IP of the machine running Docker for Mac/Windows: `- targets: ['hostname-here:9323']`
4. Save the file and exit
5. Start the Prometheus stack: `docker-compose up -d`

### Configure Grafana

1. In a new browser tab, Open Grafana: `http://0.0.0.0:3000`
2. Login to Grafana: username - `admin` password - `foobar`
3. After logging in,`to add a data source with a green button` you will be prompted with a green button to add a data source. Click `Add Data Source`
4. Input the following information into the Data Source:  
Name: `Prometheus`  
Type: `Prometheus`  
URL: `http://prometheus:9090`  
Access: Leave the `User`default  
HTTP Auth: Click `Basic Auth`  
User: `admin`  
Password: `foobar`
5. Click on the Grafana Logo in the upper right-hand corner, hover over Dashboards, and select `import`
6. Type the number `1229` in the Grafana.com Dashboard input area, click `Load`

Everything should now be populated except for the last field that requires the data source. Click the drop-down and select `prometheus` and click `Import`  

![Import Grafana Dashboard](https://storage.ghost.io/c/29/50/2950930d-60f2-422c-90aa-232fbd4873b6/content/images/2017/07/import_dashboard.png)

Click `Save & Test`  

![Configure Grafana Data Source](https://storage.ghost.io/c/29/50/2950930d-60f2-422c-90aa-232fbd4873b6/content/images/2017/07/grafana_data_source.png)

### Conclusion

We have set up the Docker Daemon to log its metrics, configured and launched a Prometheus stack to consume these metrics, and finally imported a [Grafana dashboard](https://grafana.com/dashboards/1229?ref=brianchristner.io) as a starting point. Based on this installation you should now be able to create some interesting graphs and dashboards.

Happy monitoring!

### FAQ Section: How to Monitor Docker for Mac and Windows

**Why is it important to monitor Docker on Mac and Windows?**  
Monitoring Docker on Mac and Windows is crucial for ensuring that your containers run efficiently and that system resources are used optimally. By keeping an eye on performance metrics like CPU, memory, and disk usage, you can identify potential issues before they impact your applications. Monitoring helps you maintain the health of your Docker environment and troubleshoot problems more effectively.

**What tools can I use to monitor Docker on Mac and Windows?**  
You can use several tools to monitor Docker on Mac and Windows, including built-in Docker features like Docker Dashboard, which provides a graphical overview of container status and resource usage. Third-party tools like Datadog, Prometheus, and cAdvisor offer more advanced monitoring capabilities, including real-time alerts, detailed metrics, and historical data analysis. These tools help you gain deeper insights into your Docker environment.

**How do I set up Docker Dashboard for monitoring on Mac and Windows?**  
Docker Dashboard is automatically included with Docker Desktop on both Mac and Windows. To access it, simply open Docker Desktop and click on the Dashboard icon. The Dashboard provides an overview of running containers, their resource usage, and any logs or events. It’s a straightforward tool for basic monitoring and managing your containers directly from your desktop.

**Can I monitor Docker performance metrics using command-line tools?**  
Yes, you can monitor Docker performance metrics using command-line tools like `docker stats` and `docker inspect`. The `docker stats` command provides real-time metrics for CPU, memory, network, and disk usage for running containers. `docker inspect` gives detailed information about a specific container, including its configuration and state. These tools are useful for quick checks and integrating with scripts or automation workflows.

**What should I do if I notice high resource usage in Docker on Mac or Windows?**  
If you notice high resource usage in Docker on Mac or Windows, start by identifying the containers consuming the most resources using tools like Docker Dashboard or `docker stats`. You can then optimize your containers by adjusting resource limits, optimizing your Dockerfile, or scaling down unnecessary services. In some cases, upgrading your system’s hardware or adjusting Docker Desktop’s resource allocation settings can also help improve performance.

### Follow me

If you liked this article, [Follow Me](https://twitter.com/idomyowntricks?ref=brianchristner.io) on Twitter to stay updated!

## Sign up for BrianChristner.io

I write Dockerfiles, Build Products, Share Ideas, and crash Mountain Bikes

Subscribe 

Email sent! Check your inbox to complete your signup. 

No spam. Unsubscribe anytime.