leopoodle
leopoodle

Reputation: 2492

How to COPY inside a Dockerfile to a host machine directly

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?

Upvotes: 1

Views: 153

Answers (1)

Matt
Matt

Reputation: 74871

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.

Upvotes: 1

Related Questions