0

I'm using a docker container for compiling a code that I many not necessarily want to dockerize. I have set up an image with the necessary build tools but I would like to get the compiled file somehow out of the container without using the docker cp container:/file host/file command. In other words, I would like automate this process so that after build is completed, the generated files would be copied to the host.

Can the copy command in Dockerfile COPY <source> <target> be used for this purpose? If no, then what is the solution?

Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76

1 Answers1

1

You can't copy from a build process to the host context using COPY.

If you need the image and also the executable on the host, then the only way I can think of is a server to push the executable to. That can be something like SSH where you use scp to copy it. Or you could use a web server and use curl to do a POST of the file. Lots of options, but they all require a server you can send the executable to.

Another option is (like you say yourself) to run the image after you've built it and then use docker cp to copy the file from the container to the host.

Hans Kilian
  • 18,948
  • 1
  • 26
  • 35