i am trying to run a cpp application within docker.After i have built the executable and created the Dockerfile , i can not run it inside docker for some reason:
main.cpp
#include<iostream>
#include<chrono>
#include<thread>
#include<string>
#include <unistd.h>
int main(int argc,char *argv[])
{
std::cout<<"Started daemon..."<<std::endl;
std::string hostString(argv[1]);
std::cout<<"HostName:"<<hostString<<std::endl;
std::cout<<"Port:"<<std::stoi(argv[2])<<std::endl;
int i=0;
while(true){
std::cout<<"Iterations:"<<i++<<std::endl;
std::this_thread::sleep_for (std::chrono::seconds(1));
if(i++>10000) i=0;
}
return 0;
}
Dockerfile
FROM ubuntu:latest
RUN mkdir -p /home/dockerc
COPY . /home/dockerc
ENTRYPOINT ["/home/dockerc/main","127.0.0.1","8350"]
dockerc folder
- main.cpp
- main.exe
- Dockerfile
I run the following:
g++ main main.cpp
docker build app .
docker images (it shows that app image is created)
docker run app
The build is succesfull but when i hit the run it looks like it blocks.It just does not continue.
What is wrong?Could someone help me ?I am new to docker.
P.S After waiting out for like 10 minutes i get long error message that begins with the following:
$ docker run cpapp
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container a575e463f193dbc475aab78c1810486e23981a50c 0b731f9c891c4143d0ed5b3 encountered an error during CreateProcess: failure in a Windows system call: The compute system exited unexpecte dly. (0xc0370106)

