Config options to reduce Docker.raw for docker sandboxes on Docker Desktop for Mac

Every new Docker sandbox tries to allocate 17GB of disk. For tens of coding agents that write small scripts, it’s a big overkill, as the base template image utilizes only 2.2 GB.

Is there any option for Docker config of Docker Desktop to reduce or control this size?

P.S. Docker Sandboxes doesn’t share Docker.raw for regular containers.

$ du -m  ~/.docker/sandboxes/vm/codex-docker_sandbox_test/Docker.raw
17070	/Users/dm/.docker/sandboxes/vm/codex-docker_sandbox_test/Docker.raw

$ du -m  /Users/dm/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
76930	/Users/dm/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Which agent did you try? I had a kiro agent created which was smaller than 10GB. That is still bigger than the image or the used space inside the microVM. It looks like the disk size is caused by filesystem operations inside the micro VM when docker pulls image layers and extracts them. Writing and deleting files can increase the VM size if the operating system doesn’t write the same space. I noticed the increasing disk size while pulling the kiro image.

I ran this in one terminal window:

watch 'du -sh ~/.docker/sandboxes/vm/kiro-sandbox/*'

It failed iuntil the fodler was created.. But then I ran this in another terminal window:

docker sandbox create kiro .

I saw the usual Docker pull logs and the VM size increased to about 10GB again. Originally it was 9.5 GB, but the newly created sandbox was 9.8 GB. I don’t know if it was the result of a the filesystem written differently or a new version was pulled.

I don’t know how it can be optimized, but it is an interesting feedbak I never thought of.

It was Codex.

$ du -m  ~/.docker/sandboxes/vm/codex-docker_sandbox_test/Docker.raw
17070	/Users/dm/.docker/sandboxes/vm/codex-docker_sandbox_test/Docker.raw

$ docker --context codex-docker_sandbox_test system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          1         1         2.269GB   2.269GB (100%)
Containers      1         1         2.109MB   0B (0%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B

$ docker --context codex-docker_sandbox_test image ls
                                                                                                                                                                                             i Info →   U  In Use
IMAGE                            ID             DISK USAGE   CONTENT SIZE   EXTRA
docker/sandbox-templates:codex   f65798aaa8e7       2.27GB          614MB    U

$ docker --context codex-docker_sandbox_test volume ls
DRIVER    VOLUME NAME

$ docker sandbox exec codex-docker_sandbox_test du -xhd 1 / 2>/dev/null | sort -h | tail -n 30
4.0K	/boot
4.0K	/media
4.0K	/mnt
4.0K	/opt
4.0K	/root
4.0K	/srv
12K	/tmp
16K	/run
20K	/Users
2.4M	/etc
20M	/var
53M	/home
1.5G	/
1.5G	/usr

I tried it with Codex as well and I got 10 GB after pulling the image like I got with Kiro. It could still increase any time youdo something in the sandbox that needs to write the filesystem. Sometimes writing different parts of the disk is better so it is evenly used during the years. I think this happens with SSDs, but when using a virtual disk without limited size, it can make your disk grow until it fills up your disk.

I shared this feedback internally with Docker, but I see you also opened a ticket (thanks for that too)

For Kiro, the same. What virtualization frameworks and docker desktop do you use?

Btw, the max limit may be set, it will not eat up all the space. Even Docker.raw for all regular containers has the max tunable limit. I set it to 96.86GB as a max size. You may check max possible size by running ls without -s option.

$ ls -lh /Users/woz/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
-rw-r--r-- 1 woz staff 97G Feb 20 06:21 /Users/woz/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

For actual allocation, add the -s option or use du.

$ ls -lsh /Users/woz/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
76G -rw-r--r-- 1 woz staff 97G Feb 20 06:21 /Users/woz/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
 $ du -m ~/.docker/sandboxes/vm/kiro-docker_sandbox_test/Docker.raw
17492	/Users/woz/.docker/sandboxes/vm/kiro-docker_sandbox_test/Docker.raw

$ docker --context kiro-docker_sandbox_test image ls
                                                                                                                                                                                             i Info →   U  In Use
IMAGE                           ID             DISK USAGE   CONTENT SIZE   EXTRA
docker/sandbox-templates:kiro   e32b7222fe35       2.71GB          785MB    U

$ docker --context kiro-docker_sandbox_test system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          1         1         2.714GB   2.714GB (100%)
Containers      1         1         2.097MB   0B (0%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B

Update: sorry, posted the response in the wrong topic.