Docker CLI fails on Windows due to NamedTemporaryFile lock — unable to start containers
Describe the bug
After installing llmstack library, when running llmstack on Windows, the CLI fails to start due to a locked temp file used as the --env-file for docker compose. This is caused by NamedTemporaryFile keeping the file open, which prevents Docker from accessing it.
Error
C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt: The process cannot access the file because it is being used by another process.Traceback (most recent call last):
File "
python_on_whales.exceptions.DockerException: The docker command executed was C:\Program Files\Docker\Docker\resources\bin\docker.EXE compose --file D:\Practice\GenAI\Multi-Agents.venv\Lib\site-packages\llmstack\docker-compose.yml --env-file C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt up --detach --pull missing.
It returned with code 1
The content of stdout can be found above the stacktrace (it wasn't captured).
The content of stderr is 'open C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt: The process cannot access the file because it is being used by another process.
'
Version Version of LLMStack this issue is seen in: 0.2.6.
Environment I am running it on Windows. Faced a similar issue in Mac as well
Root cause Python's NamedTemporaryFile holds an open file handle, which causes access conflicts on Windows due to exclusive locks.
Proposed fix Switch to using NamedTemporaryFile(delete=False) and close the file before passing its path to Docker. Clean up the file afterward.
Offer to contribute I’m interested in contributing a fix for this issue. If maintainers are okay with this approach, I can submit a PR