I am new to Docker and need some help. I want to make an interactive docker image for a c code. I have written a small c code for the same. The below is my c code:
**CODE:**
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,sum=0,n,num[10];
printf("How many integers do you want to enter? ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
sum+=num[i];
}
printf("Total Sum: %d\n",sum);
printf("---------------------\n\n");
return 0;
}
OUTPUT:
How many integers do you want to enter? 3(User Input)
1 3 5(User Input)
Total Sum: 9
**DockerFile code**
File: Dockerfile
FROM debian:latest
RUN mkdir -p /home/arup123/ExtendedAdd
COPY . /home/arup123/ExtendedAdd
CMD /home/arup123/ExtendedAdd/ExtendedAddition
My Attempt
I thought we could create an interactive shell like bash shell within the current shell to take user input but i am getting "Segmentation fault (core dumped)"
docker build -t image1 .
docker run -it --name image2 image1 /bin/bash
/# 3
bash: 3: command not found
/# 1 2 3
bash: 1: command not found
/# exit
exit
docker commit image2 myuser/myimage:2.1
# docker run e2807f8b1966(image id of image1)
Segmentation fault (core dumped)
Please do let me know where I am going wrong and how i could correct the same!
-Thank you