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
Loading
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.