File: desktop/windows/index.md
We have the line
Disk image size: Specify the size of the disk image.
In docker desktop it said
You are using the WSL 2 backend, so resource limits are managed by Windows.
You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file.
Now in microsoft wsl docs, there are no where to be found that how I can change the size of disk image ?
So how, where can I change these resource ?
In my docker desktop images tab, it said the total size is 2.27GB (why 2.27, I don’t know), even after add wslconfig file with memory=4GB # Limits VM memory
, that doesn’t change
|
eww 0 / 0 / 0 Регистрация: 01.03.2021 Сообщений: 40 |
||||
10.04.2024, 13:38. Показов 987. Ответов 5 Метки docker, docker-desktop (Все метки) Добрый день. У меня немного старенький(наверное) игровой ноут с 8Гб ОЗУ и процессор i5 8 ядерный. Хотел научиться пользоваться Docker-ом установил и запустил Docker Desktop и оно сразу заняло 81% ОЗУ(8) это притом что я на фоне не запускал IDE и другие программы. Покопался в интернете в официальном сайте написано 4Gb ОЗУ достаточна, хотя везде пишут что мин требования 16Гб или даже 32Гб что кажется слишком заоблачным(может и не так). Некоторые люди предлагают снести ОС затем запускать в Linux. Какое решение является самым оптимальным для запуска Docker, есть ли какие то способы оптимизации при запуске чтобы оно не требовала так много ресурсов при запуске ? P.S Еще после запуска когда выхожу из самого Docker Desktop оно не закрывается, приходилось постоянно через cmd прописывать команду:
, затем отключать Docker Desktop через снять задачу.
0 |
13428 / 8959 / 1324 Регистрация: 21.01.2016 Сообщений: 33,633 |
|
12.04.2024, 10:40 |
|
Сообщение от eww запустил Docker Desktop и оно сразу заняло 81% ОЗУ(8) Не может быть. Что за «оно» заняло столько памяти? Сама графическая оболочка много не занимает. Сам докер, без поднятых контейнеров тоже ничего не потребляет. Вообще, я по несколько контейнеров поднимал на OrangePI с 2Гб оперативки и всё ок было.
0 |
0 / 0 / 0 Регистрация: 01.03.2021 Сообщений: 40 |
|
17.04.2024, 08:19 [ТС] |
|
Usaga, я не поднимал никаких контейнеров, но когда запускаю сам docker запускается и задача Vmmem который и как раз занимает большое количество ОЗУ. Я хотел вручную распределять ресурсы внутри Settings но там написано: You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file.
0 |
13428 / 8959 / 1324 Регистрация: 21.01.2016 Сообщений: 33,633 |
|
17.04.2024, 08:33 |
|
Сообщение от eww запускается и задача Vmmem который и как раз занимает большое количество ОЗУ Прямо со старта? У меня этот процесс тоже иногда начинает оперативку выжирать, но только после активной работы с докером, не со старта. Единственное, что помогает — перезагрузка.
0 |
0 / 0 / 0 Регистрация: 01.03.2021 Сообщений: 40 |
|
17.04.2024, 20:22 [ТС] |
|
Usaga, да со старта занимает больше памяти именно процесс vmmem но со временем его потребление ОЗУ начинает падать(упал до 300мб но очень медленно). Этот процесс сразу запускается когда открываю Docker Desktop но когда я выхожу из графической оболочки через Quit, оно все равно продолжает работать на заднем фоне. Причем Docker Desktop тоже, то есть если сделать Quit то сама GUI закрывается но не полностью а продолжает работать в заднем фоне. Есть какой то способ чтобы после Quit закрылось и GUI и Vmmem?
0 |
13428 / 8959 / 1324 Регистрация: 21.01.2016 Сообщений: 33,633 |
|
18.04.2024, 07:39 |
|
eww, ну, сам Docker Desktop не занимает много памяти, когда закрыт. А вот Vmmem это WSL и оно не закрывается докером. Тупо потому, что может быть нужно и вне докера. Поэтому только Ну и вообще, если дело дошло до того, что тебе докер понадобился, то было бы разумнее докинуть плашку оперативки в ноут…
0 |
BasicMan Эксперт 29316 / 5623 / 2384 Регистрация: 17.02.2009 Сообщений: 30,364 Блог |
18.04.2024, 07:39 |
Помогаю со студенческими работами здесь Настройка хранения данных в Docker Desktop Docker desktop windows hypervisor is not present Docker Desktop не копирует некоторые файлы Docker Desktop Windows. Настройка портов Установил Docker Desktop на ОС Windows 10. Вопрос… Можно ли где-то скачать определенную версию Docker Desktop или установить? Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 6 |
Новые блоги и статьи
Все статьи Все блоги / |
||||
Реализация DI в PHP
Jason-Webb 13.05.2025 Когда я начинал писать свой первый крупный PHP-проект, моя архитектура напоминала запутаный клубок спагетти. Классы создавали другие классы внутри себя, зависимости жостко прописывались в коде, а о. . . |
Обработка изображений в реальном времени на C# с OpenCV
stackOverflow 13.05.2025 Объединение библиотеки компьютерного зрения OpenCV с современным языком программирования C# создаёт симбиоз, который открывает доступ к впечатляющему набору возможностей. Ключевое преимущество этого. . . |
POCO, ACE, Loki и другие продвинутые C++ библиотеки
NullReferenced 13.05.2025 В C++ разработки существует такое обилие библиотек, что порой кажется, будто ты заблудился в дремучем лесу. И среди этого многообразия POCO (Portable Components) – как маяк для тех, кто ищет. . . |
Паттерны проектирования GoF на C#
UnmanagedCoder 13.05.2025 Вы наверняка сталкивались с ситуациями, когда код разрастается до неприличных размеров, а его поддержка становится настоящим испытанием. Именно в такие моменты на помощь приходят паттерны Gang of. . . |
Создаем CLI приложение на Python с Prompt Toolkit
py-thonny 13.05.2025 Современные командные интерфейсы давно перестали быть черно-белыми текстовыми программами, которые многие помнят по старым операционным системам. CLI сегодня – это мощные, интуитивные и даже. . . |
Конвейеры ETL с Apache Airflow и Python
AI_Generated 13.05.2025 ETL-конвейеры – это набор процессов, отвечающих за извлечение данных из различных источников (Extract), их преобразование в нужный формат (Transform) и загрузку в целевое хранилище (Load). . . . |
Выполнение асинхронных задач в Python с asyncio
py-thonny 12.05.2025 Современный мир программирования похож на оживлённый мегаполис – тысячи процессов одновременно требуют внимания, ресурсов и времени. В этих джунглях операций возникают ситуации, когда программа. . . |
Работа с gRPC сервисами на C#
UnmanagedCoder 12.05.2025 gRPC (Google Remote Procedure Call) — открытый высокопроизводительный RPC-фреймворк, изначально разработанный компанией Google. Он отличается от традиционых REST-сервисов как минимум тем, что. . . |
CQRS (Command Query Responsibility Segregation) на Java
Javaican 12.05.2025 CQRS — Command Query Responsibility Segregation, или разделение ответственности команд и запросов. Суть этого архитектурного паттерна проста: операции чтения данных (запросы) отделяются от операций. . . |
Шаблоны и приёмы реализации DDD на C#
stackOverflow 12.05.2025 Когда я впервые погрузился в мир Domain-Driven Design, мне показалось, что это очередная модная методология, которая скоро канет в лету. Однако годы практики убедили меня в обратном. DDD — не просто. . . |
Наверх
Windows Docker Desktop container high memory usage
If you using Docker Desktop on Windows, so you know what is WSL. The WSL stands for Windows Subsystem for Linux (WSL) and it helps run a GNU/Linux environment on Windows.
Usually, you will get the below error screen when installing Docker Desktop the first time on Windows.
We complete our WSL2 setup by the steps mentioned on https://aka.ms/wsl2kernel
In this blog, we going to discuss the Docker RAM usage issue and solutions for limiting RAM usage.
System slowness
After installing Docker Desktop, I installed the Laravel Admin Panel application. When I run the application I face a slowness issue on my Laptop. So I decided to check the memory usage.
How to check Memory usage
So I opened a task manager. The VmmemWSL memory usage is around 7GB.
You can also check the RAM usage at bottom of the Docker Desktop.
Also, you can check the memory and swap space allocated to WSL usage by using the below command on the WSL terminal.
How to limit Memory usage
The Docker Desktop resource configuration is available under Setting->Resources->Advanced menu. You can control the RAM and CPU usage.
Hyper-V mode
WSL mode
But we using WSL mode. So we will get the below message on the Resources Advance tab.
You are using the WSL 2 backend, so resource limits are managed by Windows.
You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file.
So we going to create a .wslconfig file and limit our memory usage.
1. Create a .wslconfig file
Create .wslconfig manually on the below path then add our settings.
C:\Users\\.wslconfig
You can also create files by using the Windows command on Powershell. It will create a .wslconfig file and open it on the notepad.
notepad "$env:USERPROFILE/.wslconfig"
Add the memory and processor limit. All the available configurations are listed in the Example .wslconfig file on Windows documentation.
[wsl2] memory=4GB processors=2
2. Restart the Docker Desktop
Right-click the Docker Desktop icon and click Restart. After that start your application.
3. Verify memory limit
Now time to check the memory usage. Check the memory usage on the task manager or Docker Desktop bottom or run the free -h — giga
command on the WSL terminal.
On the Docker Desktop bottom, you are able to see the RAM usage.
Now the Docker memory usage is under 4GB.
How to Monitor Docker Container Memory and CPU Usage
Docker Stats command
The docker build-in docker stats command is used to view the amount of resources your containers are using. It streams usage data for running containers.
This docker stats command only lists the live data. So it is difficult to overall and summary of analyze the memory and CPU usage.
The docker released the Resource Usage extension, so you view your usage and the ability to analyze the data for better insights.
Docker Resource Usage extension
The Resource Usage extension is used to Monitor Container Memory and CPU Usage in Docker Desktop.
To install the extension click this link or type “Resource usage” on Add extension page.
After installing, you see the “Resource usage” menu on the sidebar. Click and view your container Memory and CPU Usage.
Chart view will give a graphical view of CPU and memory usage.
Conclusion
We limited the memory usage of Docker Desktop on WSL mode. Earlier Docker used half of my RAM, now I updated the config to use 25% of my RAM (My system’s total RAM size is 16GB).
The system is running fast while using Docker. But if you face slowness on the application means increasing the RAM size on .wslconfig.
Thank you for reading.
Stay tuned for more!
Follow me at balajidharma.medium.com.
Перейти к контенту
As the title reads, I’m trying to assign more memory to my container. I’m using an image from docker hub called «aallam/tomcat-mysql» in case that’s relevant.
When I start it normally without any special flags, there’s a memory limit of 2GB (even though I read that memory is unbounded if not set)
Here are my docker stats
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
ba57d6c9e9d2 0.22% 145.6 MiB / 1.952 GiB 7.29% 508 B / 508 B 0 B / 6.91 MB 68
I tried setting memory explicitly like so but with same results
docker run -d --memory=10g --memory-swap=-1 -e MYSQL_PASSWORD=password -p 3307:3306 -p 8081:8080 aallam/tomcat-mysql
I’ve read that perhaps the VM is what’s restricting it. But then why does docker stats show that container size limit is 2GB?
mohan08p
5,0301 gold badge28 silver badges36 bronze badges
asked Jun 13, 2017 at 23:59
That 2GB
limit you see is the total memory of the VM (virtual machine) on which docker runs.
If you are using Docker Desktop you can easily increase it from the Whale 🐳 icon in the task bar, then go to Preferences -> Advanced:
But if you are using VirtualBox behind, open VirtualBox, Select and configure the docker-machine assigned memory.
See this for Mac:
https://docs.docker.com/desktop/settings/mac/#advanced
MEMORY
By default, Docker for Mac is set to use 2 GB runtime memory, allocated from the total available memory on your Mac. You can increase the RAM on the app to get faster performance by setting this number higher (for example to 3) or lower (to 1) if you want Docker for Mac to use less memory.
For Windows:
https://docs.docker.com/desktop/settings/windows/#advanced
Memory — Change the amount of memory the Docker for Windows’ Linux VM uses
answered Jun 14, 2017 at 0:15
RobertRobert
33.7k8 gold badges90 silver badges94 bronze badges
9
Allocate maximum memory to your docker machine from (docker preference -> advance )
Screenshot of advance settings:
This will set the maximum limit docker consume while running containers. Now run your image in new container with -m=4g flag for 4 gigs ram or more. e.g.
docker run -m=4g {imageID}
Remember to apply the ram limit increase changes. Restart the docker and double check that ram limit did increased. This can be one of the factor you not see the ram limit increase in docker containers.
aschipfl
33.7k12 gold badges54 silver badges99 bronze badges
answered Dec 12, 2018 at 12:45
If you want to change the default container and you are using Virtualbox, you can do it via the commandline / CLI:
docker-machine stop
VBoxManage modifyvm default --cpus 2
VBoxManage modifyvm default --memory 4096
docker-machine start
answered Jan 28, 2018 at 2:05
BrentBrent
1,3341 gold badge15 silver badges22 bronze badges
Screen shots for Docker Desktop V3.3.3 (Mac)
answered Jun 17, 2021 at 3:11
Derek SoikeDerek Soike
11.3k3 gold badges79 silver badges74 bronze badges
2
File: desktop/windows/index.md
We have the line
Disk image size: Specify the size of the disk image.
In docker desktop it said
You are using the WSL 2 backend, so resource limits are managed by Windows.
You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file.
Now in microsoft wsl docs, there are no where to be found that how I can change the size of disk image ?
So how, where can I change these resource ?
In my docker desktop images tab, it said the total size is 2.27GB (why 2.27, I don’t know), even after add wslconfig file with memory=4GB # Limits VM memory
, that doesn’t change
As the title reads, I’m trying to assign more memory to my container. I’m using an image from docker hub called «aallam/tomcat-mysql» in case that’s relevant.
When I start it normally without any special flags, there’s a memory limit of 2GB (even though I read that memory is unbounded if not set)
Here are my docker stats
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
ba57d6c9e9d2 0.22% 145.6 MiB / 1.952 GiB 7.29% 508 B / 508 B 0 B / 6.91 MB 68
I tried setting memory explicitly like so but with same results
docker run -d --memory=10g --memory-swap=-1 -e MYSQL_PASSWORD=password -p 3307:3306 -p 8081:8080 aallam/tomcat-mysql
I’ve read that perhaps the VM is what’s restricting it. But then why does docker stats show that container size limit is 2GB?
mohan08p
5,0301 gold badge28 silver badges36 bronze badges
asked Jun 13, 2017 at 23:59
That 2GB
limit you see is the total memory of the VM (virtual machine) on which docker runs.
If you are using Docker Desktop you can easily increase it from the Whale 🐳 icon in the task bar, then go to Preferences -> Advanced:
But if you are using VirtualBox behind, open VirtualBox, Select and configure the docker-machine assigned memory.
See this for Mac:
https://docs.docker.com/desktop/settings/mac/#advanced
MEMORY
By default, Docker for Mac is set to use 2 GB runtime memory, allocated from the total available memory on your Mac. You can increase the RAM on the app to get faster performance by setting this number higher (for example to 3) or lower (to 1) if you want Docker for Mac to use less memory.
For Windows:
https://docs.docker.com/desktop/settings/windows/#advanced
Memory — Change the amount of memory the Docker for Windows’ Linux VM uses
answered Jun 14, 2017 at 0:15
RobertRobert
33.7k8 gold badges90 silver badges94 bronze badges
9
Allocate maximum memory to your docker machine from (docker preference -> advance )
Screenshot of advance settings:
This will set the maximum limit docker consume while running containers. Now run your image in new container with -m=4g flag for 4 gigs ram or more. e.g.
docker run -m=4g {imageID}
Remember to apply the ram limit increase changes. Restart the docker and double check that ram limit did increased. This can be one of the factor you not see the ram limit increase in docker containers.
aschipfl
33.7k12 gold badges54 silver badges99 bronze badges
answered Dec 12, 2018 at 12:45
If you want to change the default container and you are using Virtualbox, you can do it via the commandline / CLI:
docker-machine stop
VBoxManage modifyvm default --cpus 2
VBoxManage modifyvm default --memory 4096
docker-machine start
answered Jan 28, 2018 at 2:05
BrentBrent
1,3341 gold badge15 silver badges22 bronze badges
Screen shots for Docker Desktop V3.3.3 (Mac)
answered Jun 17, 2021 at 3:11
Derek SoikeDerek Soike
11.3k3 gold badges79 silver badges74 bronze badges
2
Under some circumstances, you might want to change the folder that stores your Docker images and containers. For example, you are running Docker Desktop on a Windows laptop or a Macbook with only 256GB or 512GB of storage and it is almost out of free space. In this case, you can move your images and containers to a bigger drive or external storage.
By default, Docker Desktop stores your images and containers at:
- C:/ProgramData/DockerDesktop/vm-data on Windows
- /Users/<your username>/Library/Containers/com.docker.docker/Data/vms/0/data on Mac
Important Note: If you’re using WSL (Windows Subsystem for Linux) 2 Backend, see the later section of this article
The Steps
If you’re running Docker Desktop on a Mac or a Windows computer (without using WSL 2 Backend), then you can change this location by following the steps below:
1. Go to your Docker Desktop dashboard and select Settings:
2. Navigate to Resources > Advanced and scroll down a little bit to see the Disk image location area:
3. Click on the Browse button and choose a new directory for your images and containers:
4. Last but not least, click the Apply & Restart button to finish:
Docker Desktop will take care of the rest.
The Steps For Windows Users with WSL 2 Backend
A large portion of Windows users run Docker Desktop on WSL 2 (the Windows Subsystem for Linux built by Microsoft) due to various benefits such as:
- Leveraging Linux workspaces and avoiding having to maintain both Linux and Windows build scripts
- Improving file system sharing, and boot time and allowing access to some cool new features for Docker Desktop
To change containers and images directory in this case, walk through the following steps:
1. Exit Docker Desktop
2. Shutdown WSL by executing this command:
wsl --shutdown
3. Export Docker Desktop data to your home screen (you can choose another place if you like):
wsl --export docker-desktop-data C:\Users\YOURUSERNAME\Desktop\data.tar
4. Unregister current Docker Desktop data:
wsl --unregister docker-desktop-data
5. Import the exported data to your desired location (for example, a folder named kindacode in the hard drive E):
wsl --import docker-desktop-data E:\kindacode\ C:\Users\YOURUSERNAME\Desktop\data.tar --version 2
You might have to perform this step twice if you run into some network trouble.
Further reading:
- How to Install Docker Compose on Ubuntu 21.04 and 21.10
- Deleting unnecessary Images and Containers in Docker
- Docker: How to Retag an Image
- Docker: Execute Commands inside a Running Container
- Using Docker Compose to speed up WordPress development
- Using Docker Compose with Node.js and MongoDB
You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.
Другие наши интересноые статьи:
WINDOWS
Docker has revolutionized the way developers build, ship, and run applications through containerization. However, configuring Docker, especially regarding resource limits like memory allocation, differs significantly between platforms such as Windows, Mac, and Linux. In this article, we will explore how to set up configuration settings like memory limits specifically for Docker running on Windows and Windows Subsystem for Linux 2 (WSL2).
Understanding Docker on Windows and WSL2
Docker Desktop for Windows enables the use of containers on Windows systems. It leverages WSL2 to run a lightweight Linux kernel, which is crucial for compatibility with Linux containers.
Key Differences:
-
Docker on Windows uses a Hyper-V or WSL2 backend.
-
Docker on Mac employs a dedicated virtual machine.
-
Docker on Linux operates natively without the need for virtualization.
Due to these architectural differences, setting memory limits and other configurations varies across these operating systems.
Installing Docker Desktop on Windows and WSL2
Before diving into the configuration details, you need Docker Desktop installed on both Windows and WSL2.
Installation Steps:
-
Download Docker Desktop:
-
Visit the Docker Hub.
-
Download Docker Desktop for Windows.
-
-
Enable WSL2 Integration:
-
During installation, ensure to select WSL2 as your backend.
-
After installation, go to the Docker Desktop settings, and in the ‘Resources’ tab, choose the WSL Integration option.
-
-
Install WSL2:
-
Open PowerShell as Administrator and run:
-
Verify installation by launching a WSL terminal and typing:
-
Final Step:
Restart your system to ensure all changes take effect.
Configuring Memory Limits in Docker for Windows
Docker’s settings can be adjusted to manage CPU and memory allocation effectively.
Step-by-Step Configuration:
-
Open Docker Desktop:
-
Right-click the Docker icon in the system tray and select “Settings.”
-
-
Navigate to Resources:
-
In the left sidebar, click on “Resources.”
-
Here, you will see options to manage CPU, Memory, and Swap.
-
-
Adjust Memory Limits:
-
Use the slider or input box to set the ‘Memory’ limit according to your needs.
-
-
Apply Changes:
-
Click on “Apply & Restart” to make the changes take effect.
-
Example Configuration:
Assume you have a machine with 16 GB RAM and want to allocate 4 GB to Docker:
-
Set the memory limit to 4096 MB.
Configuring Memory Limits in Docker on WSL2
For users of Docker within a WSL2 environment, you must configure memory limits differently.
Configuring Docker in WSL2:
-
Create a
.wslconfig
File:-
Navigate to your home directory in Windows (
C:\Users\<username>
). -
Create or edit the file named
.wslconfig
.
-
-
Add Configuration Settings:
Here’s an example configuration to allocate resources:[wsl2] memory=4GB # Limits memory to 4 GB processors=2 # Limits CPU cores to 2 swap=8GB # Configure swap if necessary
-
Save and Exit:
After making changes, save the.wslconfig
file. -
Restart WSL2:
To apply changes, run the following command in PowerShell:
Verifying Configuration:
To check if changes were applied, open a WSL terminal and run:
This command should reflect the new memory limit.
Practical Advice for Configuring Docker
-
Assess Your Resources: Before setting limits, evaluate the system resources to avoid affecting performance negatively.
-
Monitor Performance: Use tools like
docker stats
to monitor running containers’ resource utilization. -
Adjust as Needed: Periodically review and modify allocations based on application demands.
Conclusion
Configuring memory limits for Docker on Windows and WSL2 is essential for optimizing resource usage and ensuring that your containers run smoothly. Understanding the differences in configuration practices between Docker on Windows and WSL2 can help you make informed decisions to improve your development workflow.
Important Keywords:
-
Docker memory limits
-
WSL2 configuration
-
Docker on Windows
-
Docker resources management
-
Install Docker Desktop
By following the steps provided in this article, you can successfully set up and manage memory limits in Docker, tailoring your containerized applications’ performance to meet your development requirements effectively.
Suggested Articles
WINDOWS
WINDOWS
WINDOWS
WINDOWS
WINDOWS
WINDOWS