0

I am trying to dockerize a cpp application and after i build the image in docker and run it i get an error.

Error:
/bin/sh: 1:home/simple/Main: not found

main.cpp

 #include<iostream>

 int main(){
 std::cout<<"Hellow World";
 return 0;
 }


I compile this with : g++ -o Main main.cpp

Dockerfile

FROM ubuntu:latest
RUN mkdir -p /home/simple
COPY . /home/simple
CMD home/simple/Main

Docker commands
docker build -t myapp .
docker run myapp

P.S I have followed this guide :https://www.youtube.com/watch?v=kejsVBoP4kE

How can it not find the executable since it it is in the same folder with the Dockerfile.When i run COPY . /home/simple could it somehow happen to copy only 1/2 of the files?

P.S.2 After setting the ENTRYPOINT ["ls","-l","/home/simple/"] the returned files were 0.
It seems that the ADD/COPY . /home/simple/ does not work.No files are copied.

7
  • 1
    Maybe CMD /home/simple/Main ?
    – harrymc
    Sep 21, 2018 at 8:25
  • I have tried.It still reports the same error. Sep 21, 2018 at 8:28
  • 1
    Better show us the contents of your folder.
    – harrymc
    Sep 21, 2018 at 9:39
  • Ok so i found the problem.Apparently the COPY command does not work.I have used as an entrypoint ENTRYPOINT ["ls","-l","/home/simple/"] and there are no files in.I have also tried the ADD src dest version and still it does not copy anything in the image. Sep 21, 2018 at 9:46
  • 1
    Maybe add WORKDIR /home/simple. Or your current path is wrong.
    – harrymc
    Sep 21, 2018 at 9:58

1 Answer 1

0

You are missing the forward slash infront of the word home, on the last line. Change: CMD home/simple/Main To: CMD /home/simple/Main

2
  • I added the slash as another user pointed out in a comment.It still prints the same error. Sep 21, 2018 at 9:13
  • Is the MODE correct on the executable? Maybe before trying to run it, try adding chmod 0755 /home/simple/Main
    – PyTis
    Sep 21, 2018 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .