I want to get some files when dockerfile built successfully, but it doesn't copy files from container to host.
That means when I have built dockerfile, the files already be host.
I want to get some files when dockerfile built successfully, but it doesn't copy files from container to host.
That means when I have built dockerfile, the files already be host.
When you build, you have the opportunity to copy files from host to the image you are building (with the
COPY
directive orADD
)You can also copy files from a container (an image that has been
docker run
'd) to the host with docker cp (atually, the cp can copy from the host to the container as well)But you cannot copy "from the Dockerfile": the Dockerfile is just a recipe specifying how to build an image.
If you want to get back to your host some files that might have been generated during the build (like for example calling a script that generates ssl), you can run a container, mounting a folder from your host and executing cp commands.
See for example this getcrt script.
Everything between
COMMANDS
are commands executed on the container, includingcp
ones which are copying on the host${HOME}/b2d/apache
folder, mounted within the container as/apache
with-v ${HOME}/b2d/apache:/apache
.That means each time you copy anything on
/apache
in the container, you are actually copying in${HOME}/b2d/apache
on the host!