I changed the original Dockerfile, because in UV documentation the Dockerfile looks this, but I guess the bin folder only applies to IOs, and for windows its called Scripts, so I changed lines 4 and 14 from /bin to /Scripts (I don't think that's the problem)
That is absolutely the problem.
You're not running in a Windows container; you're running a Linux container. The default $PATH (the variable in which the system will search for unqualified binary names like uv) typically includes /bin, but it does not include /Scripts.
By placing the uv binary in /Scripts, you have placed it where it won't be found.
- You could add
/Scriptsto your$PATH, and then you could runuvand it would work. - You could call it with a fully qualified path, like
/Scripts/uv.
But the easiest solution is to not makes changes just for the sake of changing things: put the binaries in /bin as documented and they will work as expected.
With the following Dockerfile, everything works as expected:
FROM python:3.11
# Install uv.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Copy the application into the container.
COPY . /app
# Install the application dependencies.
WORKDIR /app
RUN uv sync --frozen --no-cache
# Run the application.
CMD ["/app/.venv/bin/uvicorn", "src.main:app", "--port", "80", "--host", "0.0.0.0"]
Answer from larsks on Stack OverflowHave `uv sync` default to `--locked`
uv sync on a docker container requires `--frozen` instead of `--locked`
python - How to prevent unmanaged packages from being removed and set uv sync --inexact --frozen as the default behavior when using uv for dm? - Stack Overflow
Add --frozen flag to "sync-and-running" documentation
I've been having lots of fun using Astral's uv and also teaching it to friends and students, so I decided to create a cheatsheet with the most common/useful commands.
uv cheatsheet with most common/useful commands
I included sections about
-
project creation;
-
dependency management;
-
project lifecycle & versioning;
-
installing/working with tools;
-
working with scripts;
-
uv's interface for
pipandvenv; and -
some meta & miscellaneous commands.
The link above takes you to a page with all these sections as regular tables and to high-resolution/print-quality downloadable files you can get for yourself from the link above.
I hope this is helpful for you and if you have any feedback, I'm all ears!