Hello,
I am building docker containers. I used below sample dockerfile for building.
# Stage 1: Build stage
FROM ubuntu:latest AS build
# Install build-essential for compiling C++ code
RUN apt-get update && apt-get install -y build-essential && apt-get install bash
# Set the working directory
WORKDIR /app
# Copy the source code into the container
COPY hello.cpp .
# Compile the C++ code statically to ensure it doesn't depend on runtime libraries
RUN g++ -o hello hello.cpp -static
# Stage 2: Runtime stage
FROM scratch
#try for bash
# Copy the static binary from the build stage
COPY --from=build /app/hello /hello
# Command to run the binary
CMD ["/hello"]
I used below command ro run
sudo docker run -it cpp_helloworld
But when I checked it exited and was not running. The status was created
Later I used below command to run the container:
# : sudo docker run -it cpp_helloworld /bin/sh
# :sudo docker run -it cpp_helloworld /bin/bash
# :sudo docker run -it cpp_helloworld sh
# :sudo docker run -it cpp_helloworld bash
But I got the error saying :
3feff6b9b9fc82655c1bdcd8adecfeedee46433ff4e65de53e59f4f087b5c032
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: â/bin/shâ: stat /bin/sh: no such file or directory: unknown
Here, am I missing anything in dockerfile? or while running? Please guide me here.
regards,
Siddhartha V