Pierre-olivier Gendraud
Pierre-olivier Gendraud

Reputation: 1897

how to use cmd inside a Dockerfile to compile a file

What I want: i want to run a cpp file witch use opencv inside a container

What I've done:

installing an image of opencv:

 docker pull spmallick/opencv-docker:opencv

create a docker file

FROM spmallick/opencv-docker:opencv

COPY . .  

CMD ["g++ a.cpp a.out"] 

CMD ["./a.out"]

bash command

sudo docker build -t project_opencv . #OK sudo docker run -p 80:80 -it project_opencv

Error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "g++ a.cpp a.out": executable file not found in $PATH": unknown. ERRO[0004] error waiting for container: context canceled

Upvotes: 0

Views: 288

Answers (1)

Joe
Joe

Reputation: 429

CMD is supposed to be the entrypoint for the container.

You are looking for RUN

Upvotes: 1

Related Questions