Error parsing reference rust:1.61

Hi everyone
I’m working on a project with docker and I have a problem when I’m trying to build. The error message is : `

Error parsing reference: "rust:1.61.0 as chef" is not a valid repository/tag: invalid reference format

and I don’t know how to fix this issue. Can you please help me ?

Here my Dockerfile :

FROM rust:1.61.0 as chef
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
RUN cargo install cargo-chef

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl --bin cloud-scanner-cli

FROM alpine AS runtime
#RUN addgroup -S myuser && adduser -S myuser -G myuser
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/cloud-scanner-cli /usr/local/bin/
#USER myuser
ENTRYPOINT ["/usr/local/bin/cloud-scanner-cli"]

Please use the </> button next time to insert codes and error messages so the MarkDown filter will not alter your post utomatically. I edited your comment.

It looks like the syntax of aliasing is not recognized by the builder you use. Docker should not have a problem with this, so can you tell more about your environment?

  • Operating system
  • Docker version
  • If it is Docker Desktop then the version of Docker Desktop too
  • Please, share the command as well that you use to build the image
  • How did you install Docker exactly?

Instead of rust:1.61.0 as chef try rust:1.61.0 AS chef.

That should not matter. I always use the lowercase “as”

Hello !
Thank you for your help
Here the informations asked :

  • OS : Windows 10
  • Docker version : 17.03.1
  • Command used : docker build . --tag cloud-scanner-cli
  • I downloaded docker on

I tried with AS intead of as and it is the same result

The docker version is quite old. I am not sure if 17.03.1 already used buildkit at all or with a version that already supported multistage builds. I couldn’t find in the release notes when buildkit and multistaged builds were introduced.

Please update to a recent Docker Desktop version and try again.


1 Like

As @meyay wrote, this is a very old Docker version which means you must have a very old Docker Desktop version (this was one of my questions by the way :slight_smile: ) or some other solution instead of Docker Desktop. In this case, the version of Docker was enough to see it is too old.

Regardless of the multi-stage support, you should update your Docker to the latest version so you can find better help in the current documentation or here on the forum. It has many new features too.