1

I have a Dockerfile in which I compile something. I want to put the binary executable back to a host's directory.

Note. I know this can be done by docker cp <container ID>:path host_path, but that is NOT what I am asking about.

I want to add COPY command in the Dockerfile so it does that automatically. Is it possible?

1
  • If this were possible, you could easily hack anyone that could be fooled into building a Dockerfile (write to the host /etc/passwd, etc). Currently, building a Dockerfile is considered safe except for a DoS attack. Commented Oct 31, 2017 at 23:10

1 Answer 1

1

Docker's build process does not provide the functionality to copy files out of an image without using an intermediate step. This would need something external to manage the build workflow with additional steps like docker cp as you suggested.

Rocker may be of interest which implements it's own build system via the Docker API with an extended set of Dockers build commands. A number of the useful features that users have requested and Docker refused to add have been added here.

Features includes MOUNTing volumes from the host during the build. EXPORT/IMPORT of files from a build. Multiple FROMs, one for the "build" container, and another for the "run" container.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.