How to sync downlaoded data with local file system?

I have ollama container runs on Debian Trixie.

docker version: Docker version 26.1.5+dfsg1, build a72d7cd

The container is ran with the command docker run -d -v "/home/user/ollama:/root/.ollama" -p 11434:11434 --name ollama ollama/ollama. And I attempted to download a model with this command: docker exec -it ollama ollama run x/z-image-turbo "a cat says hello". I understand x/z-image-turbo is for mac. The problem is not related to this model.

The problem is my network bandwidth is not huge, so I occasionally need to interrupt the downloading process by ctrl+c. Sadly, when resuming with docker exec -it ollama ollama run x/z-image-turbo "a cat says hello" command. the progress is frequently reverted. For instance, the process shows that the model downloaded models reverted from 16% to 14% after resuming the operation. I tried with Linux sync, but the issue remains. Any way that can force the downloaded file will be persisted to physical disk like Linux sync? Thanks.

pulling model:  16% ▕█████████                                               ▏ 2.1 GB/ 12 GB  685 KB/s 4h20m^C
user@debian:~/ollama$ docker exec -it ollama ollama run x/z-image-turbo "a cat says hello"
pulling manifest 
pulling model:  14% ▕███████                                                 ▏ 1.8 GB/ 12 GB  972 KB/s    3h8m

I’m curious, have you tried the same without containers? Are you sure the behavior is caused by the containerized environment? I don’t know how the percentage is calculated or what happens when you cancel. For example if cancelling the process can cleanup partially downloaded files.

When you use docker exec, you just start a new process in the container. Based on your Docker version, it looks like you are using a version supported by the Debian maintainers probably called docker.io. At least this is how it is called on Ubuntu. That is not the officially supported one by Docker Inc, but in your case that doesn’t seem to be relevant. But when you run Docker CE (or Docker.io) on Linux, you still have the same Linux, just a different filesystem I think I had to run commands like sync in containers. I think it was during building an image when for some reason chmod in one instruction did not always have affect in the next. But my point is that you can use linux commands in a container if those commands are installed in the container. If something is needed and not in the image, you can either install it or you can contact the image maintainer.

Your Docker version 26 from mid 2024 is officially end-of-life, maybe it’s time for an upgrade, which usually includes some bugfixes.