1

I'm new to Docker, so apologies for this poor question.

I'm using an M1 Mac, and my dockerfile looks like this:

FROM python:3.8.1-slim

ENV PYTHONUNBUFFERED 1 
EXPOSE 8000
WORKDIR /app
COPY ./requirements.txt .
COPY ./src .
RUN pip install --verbose -r requirements.txt

CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "src.main:app"]

When I run docker build -t project . I get an error message that includes

Cargo, the Rust package manager, is not installed or is not on PATH.

I've tried adding cargo and rust to requirements.txt and playing with ENV PATH to no avail; which cargo on the host machine returns

/opt/homebrew/bin/cargo

Can someone please point me in the right direction?

Edit: I don't know why Rust is required here, but it seems like it isn't uncommon... this is where it shows up in the error:

Running command /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpfzj95ykv
Checking for Rust toolchain....

Edit 2: I reduced the number of packages in requirements.txt and that seems to have fixed it for now. Still annoyed I can't tell from the error what the issue is, and curious what the fix would be...

user8463
  • 11
  • 3
  • I'm confused. You're talking about Rust in a Dockerfile for a Python app. Why? Also, is that path to cargo on your host, or in the container? – ndc85430 Jul 25 '22 at 11:59
  • I've made some edits, I hope this is clearer! – user8463 Jul 25 '22 at 12:07
  • I see that pip tries to build some packages and it needs rust toolchain to do so. So you'll have to install rust compiler and common libraries in the image itself. – Monsieur Merso Jul 25 '22 at 12:30
  • 1
    Okay, and how do I do that? – user8463 Jul 25 '22 at 12:44
  • *"I've tried adding cargo and rust to requirements.txt and playing with ENV PATH to no avail; which cargo on the host machine returns"* - It's not about the host machine, it's about the `cargo` command inside the image. You might need some form of `RUN ` in there, like this: https://stackoverflow.com/a/58169817/2902833 – Finomnis Jul 25 '22 at 15:55
  • Does this answer your question? [When installing Rust toolchain in Docker, Bash \`source\` command doesn't work](https://stackoverflow.com/questions/49676490/when-installing-rust-toolchain-in-docker-bash-source-command-doesnt-work) – Finomnis Jul 25 '22 at 16:27

0 Answers0