On Windows 11, my docker desktop increasingly uses more disk every time I run docker-compose up. I tracked it to the size of the following file which is currently at about 100GB.
%USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx
It seems on Windows you'd need to configure the Docker resource usage through .wslconfig; however, I don't see a key on the docs to adjust max disk usage.
Related
I am working on Hyperledger Fabric ver 1.4, my server freeze when many transactions are been done. My understanding is that the old transactions or versions which are committed do not get removed but stay in the docker using disk space ( I might be wrong on this assumption ) therefore the only solution I have yet found is increasing my virtual server disk space to 120GB. 100GB for docker and 20GB to run my Front-end development.
I have looked into Alpine images but right now I do not want to take that route.
With Current Configurations I have 75GB SSD and 4GB of RAM
Is there a way to decrease the Max Disk size been used in Ubuntu
16.04 LTS 64bit Minimal?
If not, is the Maximum container size 100GB in Docker?
In GUI interface I can increase and decrease the size as show in the attached image.
GUI Interface Docker
I'm running Docker Desktop 2.2.0 on Windows 10. It appears that the disk size cannot be set beyond 64GB. I tried setting the diskSizeMiB value to 100GB in %APPDATA%\Docker\settings.json, but docker appears to ignore it and set the size to 64GB in the resulting Hyper-V VM.
"cpus": 6,
"diskSizeMiB": 102400,
The issue I'm having is older images being evicted when pulling new ones in. Even when manually expanding the HyperV disk to 100GB, docker pull deletes older images to make space for new ones.
Docker for Windows docs don't seem to explicitly mention a limit, but 64Gb ominously equals 2^16 bytes which hints at it being a technical limit.
Anyone knows of a workaround for this limitation?
Looks like I was on the right track with increasing the virtual disk size directly in Hyper-V (See this guide). The only missing piece was restarting Docker (or Windows). Once restarted, I was able to use the full disk.
With docker build, how do I specify the maximum disk space to be allocated to the runtime container?
This StackOverflow question mentioned runtime constraints, and I am aware of --storage-opt, but that concerns runtime parameters on dockerd or run docker -- and in contrast, I want to specify the limit in advance, at image build time.
(Note that I am not talking about specifying the disk footprint of the image, but rather about specifying the the maximum disk space for the container.)
You can't do this at build time. A container's max disk space can be only limited at runtime.
Now, if you are concerned that your disk might get full due to Docker stuff (images, logs, etc), what you can do is mount /var/lib/docker in a partition different than the main system partition, this way you know that getting out of space in docker won't crash your system. Or in case of Docker for Mac, you have a disk limit in the preferences.
Scenario
Windows 10 Professional
Docker 18.06.1-ce running in Windows container mode
4GB of available memory on host system
using Hyper-V virtual machine
Problem
When trying to "switch to Linux containers" via Docker's taskbar item the process fails after a couple of seconds showing an error about "Not enough memory to start Docker".
Since the host system does not have that much memory, I'd like to reduce the maximum amount of memory the global Docker machine is allowed to use (I think 2 GB is the default here). Thus, I'd like to reduce that to just 1 GB.
When having Docker running in Windows container mode, there is no "advanced" section in Docker's settings that would allow to reduct that memory assignment easily.
I was able to find the "MobyLinuxVM" using Windows' Hyper-V manager. However, when adjusting memory settings there, it is overwritten each time I start Docker and try again switching to Linux container mode.
Question
Is there a different way to define the maximum amount of memory for Docker without using the user interface (which won't work in this scenario due to the missing "advanced" section in Windows container mode - before being able to switch to Linux containers)?
After some searching I found out that settings of Docker's user interface are stored in %APPDATA%\Docker\settings.json (e.g. C:\Users\olly\AppData\Roaming\Docker), memory settings are defined in memoryMiB property.
The following solved the problem on my environement:
quit Docker
modify settings.json file using notepad %APPDATA%\Docker\settings.json in the run command prompt (Windows-Key + R)
adjust value memoryMiB to 1024 (has been 2048 before)
in Docker versions 19.x and later the property is called memoryMiB
in Docker versions 18.x and before the property was called VmMemory
save settings.json
start Docker and finally being able to use "switch to Linux containers"
Property memoryMiB in Docker versions 19.x and later
Property VmMemory in Docker versions 18.x and before
When I start docker for windows memory usage increases by almost 25% of 6 GB (that's 1.5 GB) without even running a container. I can't see the docker process that in the task manager, but I figured the memory usage by looking at the memory usages % before and after running the docker for windows program.
I'm running windows 10. How can I prevent docker from eating up all this ram.
You can change it in settings. Just decrease memory usage by the slider. Go to settings and choose the Advanced tab.
other settings:
https://docs.docker.com/docker-for-windows/#docker-settings-dialog
The solution is to create a .wslconfig file in the Windows home directory (C:\Users\<Your Account Name>).
Input the contents of the file as follows:-
[wsl2]
memory=1GB
processors=1
The memory and processors are the resources allocated to the wsl2 process. You can change the memory and processors according to your preference. This is my config on a 16GB i5 machine.
After that, restart the WSL2 process:-
Start PowerShell in admin mode and type: Restart-Service LxssManager
After that, you are good to go!
P.s.: Start docker only when it is required.