Docker multistage actix 404 error

I'm using a multistage Dockerfile to run my actix webserver. If I call my endpoints then I always get a 404 error. If I run the webserver without multistage then everything works fine.


# Build stage
FROM rust:slim-buster as builder

RUN apt-get update && \
  apt-get install -y pkg-config make g++ libssl-dev cmake libmariadb-dev-compat openssl && \
  rustup target add x86_64-unknown-linux-gnu

WORKDIR /var/www/app

COPY . .

RUN cargo build --bin my-app

# Prod stage, removing the Rust toolchain

COPY --from=builder /var/www/app/config /config
COPY --from=builder /var/www/app/target/debug/my-app /


CMD ["./my-app"]
2023-08-24T09:57:42.167Z INFO  [actix_web::middleware::logger] "GET /api/ HTTP/1.1" 404 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0" 0.000401

Shouldn't your CMD be ./isumis here?

Oops sorry I forgot to rename it. But this isn't the problem. I just forgot to rename it for the forum.

If I add the --release flag then it works.

Maybe there is an issue with caching? Have you added the target directory to your .dockerignore file?

Yes, this is my dockerignore:


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.