Steps to Run GCC Docker image on Raspberry pi:
1. Create folder with below contents:
build --> Folder
Dockerfile --> Docker image file
main.c --> C Program
2. Write a simple c program into main.c file
// C program to implement
// the above approach
#include <stdio.h>
// Driver code
int main()
{
printf("Welcome to Docker World!!!\n");
return 0;
}
3. Edit Dockerfile and write below contents
FROM gcc:latest
COPY . /build
WORKDIR /build/
RUN gcc -o main main.c
CMD [“./main”]
4. Save and Build Dockerfile, using command "docker build -t main-gcc-app ."
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/
Sending build context to Docker daemon 488.4kB
Step 1/5 : FROM gcc:latest
latest: Pulling from library/gcc
de07ba6f486e: Pull complete
84649bff67ea: Pull complete
48a2a14f59a0: Pull complete
0d41c7623f41: Pull complete
e532a4816a8d: Pull complete
d758cb5cc483: Pull complete
1a9014bafd27: Pull complete
d7ff42aa73d4: Pull complete
Digest: sha256:16aea78a24ad0c562e63fe3060d3ce85f96101ecd1db09b67b1ccd9bff7dfe4d
Status: Downloaded newer image for gcc:latest
---> 74afbe6d78a1
Step 2/5 : COPY . /build
---> 5c8449b50bb9
Step 3/5 : WORKDIR /build/
---> Running in 821db3d73da8
---> Removed intermediate container 821db3d73da8
---> b6fb3ea1b178
Step 4/5 : RUN gcc -o main main.c
---> Running in 5033bc4e8723
---> Removed intermediate container 5033bc4e8723
---> e686a8e707a2
Step 5/5 : CMD [“./main”]
---> Running in e51cd5d36d82
---> Removed intermediate container e51cd5d36d82
---> aa4223676951
Successfully built aa4223676951
Successfully tagged main-gcc-app:latest
5. Check is docker image is built "docker image ls"
6. Run docker image "docker run -it main-gcc-app" Hello world will be displayed.
Comments
Post a Comment