Encountering Challenges Mounting Directories in Distroless Images for C/C++ Applications

I’m working on creating a Dockerfile that involves two stages: in the first stage, I compile a C++ program, and in the second stage, I use a Distroless image for C++ to run it.

My approach involves saving the program’s output to a text file, which I intend to mount with the first stage so that I can access the output from the host machine.

However, I’m encountering difficulties in mounting the file and redirecting the output to the text file. I’d highly appreciate any assistance or insights on how to resolve this issue. Thank you

my dockerfile

FROM gcc:6 AS build-env
COPY /Executor /app/
RUN g++ -o my_program file.cpp -pthread

# Stage 2: Execution stage
FROM gcr.io/distroless/cc AS execution-stage
COPY --from=build-env /app /app
CMD ["./my_program ",">","output.txt"]