Skip to content

Django uv docker setup #17026

Description

@blossomsg

Question

Hello All,
I am exploring uv with docker, but facing some challenges setting up Dockerfile

for the sake of upload i have added an extension .txt
Dockerfile.txt

I am referring django for professionals book
in which they are setting pipenv with docker, but i wanted to explore with uv
I keep getting the below error

 => ERROR [stage-0 8/8] RUN --mount=type=cache,target=/root/.cache/uv     uv sync --locked --no-dev                                                                                                                                                                         0.2s 
------
 > [stage-0 8/8] RUN --mount=type=cache,target=/root/.cache/uv     uv sync --locked --no-dev:
0.220 error: failed to create directory `/nonexistent/.cache/uv`: Permission denied (os error 13)
------
Dockerfile:61
--------------------
  60 |     COPY . /app
  61 | >>> RUN --mount=type=cache,target=/root/.cache/uv \
  62 | >>>     uv sync --locked --no-dev
  63 |
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c uv sync --locked --no-dev" did not complete successfully: exit code: 2

here is the docker file snippet from the book.
Image

I referred these links
https://docs.astral.sh/uv/guides/integration/docker/#using-uv-in-docker
https://github.com/astral-sh/uv-docker-example/blob/main/Dockerfile

Did the necessary tweaks, but still facing permissions issue.
Do let me know what needs to be refactored, it would be really helpful
Thank You.

Platform

Microsoft Windows 11 Pro x64

Version

uv 0.8.2 (21fadbc 2025-07-22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions