What is Resource Saver Mode in Docker Desktop and what problem does it solve?
Published: 2023-08-16 14:53:56


Resource Saver mode is a new feature introduced in [Docker Desktop 4.22](https://www.docker.com/blog/docker-desktop-4-22/) that allows you to conserve resources by reducing the amount of memory and CPU that Docker uses. It is a game-changer for Docker Desktop users, providing a valuable solution to the challenge of managing resource consumption during application development. By intelligently adjusting resource allocation, prioritizing active containers, and dynamically scaling based on demand, Resource Saver Mode optimizes efficiency, enhances performance, and simplifies the development workflow. 

Whether you're a solo developer or part of a team, integrating Resource Saver Mode into your Docker Desktop experience can lead to smoother, more productive, and energy-efficient development processes. As Docker continues to evolve and refine its tools, features like Resource Saver Mode demonstrate the company's commitment to empowering developers with innovative solutions that make containerization more accessible and efficient than ever before.

Please Note: Resource Saver is currently an experimental feature. To access this feature, make sure you have turned on access to experimental features in settings.

## Benefits of Resource Saver Mode

The resource saver feature is meant to significantly reduce Docker Desktop’s memory and CPU usage on the host when no containers are running, to improve overall user experience. It will reduce memory utilization by 2GBs (or more) when Docker Desktop goes idle. In the earlier version of Docker Desktop v4.21, the feature would simply pause processes in the Docker Desktop Linux VM, but in v4.22, Docker Team improved it to shutdown the Docker Desktop Linux VM.

When Docker Desktop is paused, the Linux VM running Docker Engine is paused, the current state of all your containers are saved in memory, and all processes are frozen. This reduces the CPU and memory usage and helps you retain a longer battery life on your laptop.You can either manually pause Docker Desktop or turn on the Resource Saver feature which automatically pauses Docker Desktop when no container is running.

Here are a few benefits of integrating Resource Saver Mode to your Docker Desktop:


## 1. Enhanced Performance

One of the most significant benefits of Resource Saver Mode is the improved performance it offers during development. By intelligently managing resource allocation, it ensures that active containers receive the necessary resources to operate efficiently, leading to faster build times and better application responsiveness.

## 2. Optimized Resource Utilization

Resource Saver Mode prevents resource wastage by dynamically adjusting resource allocation based on container activity. This ensures that developers can run multiple containers simultaneously without worrying about resource conflicts or system slowdowns.

## 2. Efficient Multitasking

For developers who often work on multiple projects or need to switch between different containers, Resource Saver Mode optimizes multitasking. It guarantees that the right resources are allocated to the right containers, allowing for a seamless transition between development tasks.

Previously, Docker Desktop introduced some CPU optimizations of Resource Saver, which, at the time of writing, are already saving up to a staggering 38,500 CPU hours every single day across all Docker Desktop users.

## How to Enable Resource Saver Mode

Resource Saver mode can be enabled in the Docker Desktop settings. To do this, open the Docker Desktop app and click on the Settings icon in the top right corner. Then, click on the Features in Development tab and choose the Experimental Feature tab to enable Resource Saver Mode.



![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ntbin4ogwjyd7986w4uk.png)


## Is Resource Saver available for Windows?

Yes, Resource Saver is available for both Windows Hyper-V and MacOS. It optimises Docker Desktop’s usage of your system resources when no containers are running. To access this feature, make sure you have turned on access to experimental features in settings.

## What happens when Resource Saver Mode is enabled

When Resource Saver mode is enabled, Docker turns off the Linux VM when Docker Desktop goes idle, but once Docker Desktop gets busy (e.g., user runs a container), then the container will get the same amount of CPU & Memory as it would have without resource saver enabled.

## How Docker Desktop exits Resource Saver Mode

Docker Desktop exits resource saver mode automatically whenever a Docker command is executed that requires the Docker engine to take action. Please note that Docker commands that retrieve status such as docker ps, docker image ls, etc. do not require exit from resource saver mode as Docker Desktop cache these while entering resource saver mode, before shutting off the Linux VM.

## How does it work?

To see this feature in action, start Docker Desktop and leave it idle for 30 seconds with no containers running. A leaf will appear over the whale icon in your Docker Desktop menu and the sidebar of the Docker Desktop dashboard, indicating that Resource Saver mode is activated.


![Image6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pka0il4t70n4bo3d1np3.png)

## How to Configure Resource Saver Mode Delay

In addition to enabling Resource Saver Mode in the Docker Desktop settings, you can also configure the delay for entry into resource saver mode. This is useful if you want to give Docker Desktop a longer period of time to finish any pending tasks before it is paused.

To configure the delay for entry into resource saver mode, you can edit the settings.json file and set the autoPauseTimeoutSeconds property to a desired delay in seconds. The default value is 30 seconds, but you can set it to any value you like.

For example, to set the delay to 60 seconds, you would add the following line to the settings.json file:

```
"autoPauseTimeoutSeconds": 60
```

Once you have saved the settings.json file, Docker Desktop will pause after 60 seconds of inactivity. This will help to reduce the amount of resources that Docker Desktop uses, while still allowing you to make changes to your code and see the results in real time.

## Why a few of my containers start up slowly?

When Resource Saver mode is enabled, you may notice that some containers start up more slowly. This is because Docker is not pre-allocating resources for these containers. However, once the containers are up and running, they should use less resources than they would in normal mode.

## Resource Saver with Limited Resources

If you are running Docker on a machine with limited resources, you may want to consider enabling Resource Saver mode. This can help to improve the performance of your machine and can help to prevent Docker from running out of resources.


## Top Tips for Developers

Here are some things to keep in mind when using Resource Saver mode:

- Resource Saver mode may not be appropriate for all workloads. If you have containers that need to start up quickly or that use a lot of resources, you may want to disable Resource Saver mode for those containers.

- Resource Saver mode can affect the performance of some containers. If you notice that a container is running slowly after you enable Resource Saver mode, you may want to disable it for that container.

- Resource Saver mode is not available on all platforms. It is currently only available on Windows and macOS.


## Improved Battery Life (Laptop Users)

Laptop users can benefit from extended battery life when using Docker Desktop with Resource Saver Mode. By preventing unnecessary resource consumption, the mode helps reduce power usage, ultimately prolonging the battery life of portable devices.

## Simplified Development Workflow

With Resource Saver Mode, developers can focus on writing code and building applications without being burdened by manual resource management. The mode's automated adjustments ensure that containers receive the appropriate resources, freeing developers from the need to constantly monitor and adjust settings.

## Does the resource saver mode lead to a cold start for the containers ?

Resource Saver Mode in Docker Desktop is designed to optimize resource utilization and enhance performance by intelligently managing the allocation of system resources to containers. While it may involve some adjustments to resource allocation, it does not directly cause a cold start for containers.

Cold start typically refers to the initial boot-up process of a container where the application and its dependencies are loaded into memory and executed. Cold starts can sometimes lead to longer startup times as the necessary resources are fetched and initialized. However, Resource Saver Mode does not inherently trigger cold starts for containers.

Resource Saver Mode focuses on dynamically adjusting resource allocation based on container activity and demand. It may involve reallocating resources among running containers to ensure that active containers receive the necessary resources for optimal performance. This can help prevent resource wastage and ensure that the resources are available when they are needed.

Containers that are actively being used or have higher priority will be allocated more resources, while containers with lower activity or lower priority may have their resource allocation scaled down temporarily. This adjustment is more about efficient utilization of resources during runtime rather than causing cold starts.

In summary, Resource Saver Mode does not directly lead to cold starts for containers. Its primary goal is to optimize resource usage and improve performance during development by intelligently managing resource allocation based on container activity and demand.


## Facing issues?

You can un this diagnostics command while in the broken state:

```
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose gather -upload 
```

Further Readings:
- [Docker Desktop 4.22: Resource Saver, Compose ‘include’, and Enhanced RBAC Functionality](https://www.docker.com/blog/docker-desktop-4-22/)
- [Docker Desktop 4.22 Release Notes](https://docs.docker.com/desktop/release-notes/#4220)