I am creating a Dockerfile, where my remote repo is cloned, then built.
Can I map that output folder inside Docker container to a local folder so that to have the build result in it?
I am creating a Dockerfile, where my remote repo is cloned, then built.
Can I map that output folder inside Docker container to a local folder so that to have the build result in it?
For something like this, I would not use docker build
. Instead, create a Docker image that contains the necessary tools to build your project and use it as a "compiler". In the end, you want to be able to do:
$ docker run -v $(pwd):/output compiler
Building the project using a command has a lot of advantages over doing it during docker build
:
nginx
image)Not "mapped" from the container as such. Building and maps/mounts don't really coexist (unless you use something like rocker to build). You can get a copy of the data from the built image though.
Via tar
.
docker run --rm IMAGE tar -cf - /clone | tar -xvf -
Or docker cp
CID=$(docker create IMAGE)
docker cp $CID:/clone ./
docker rm -f $CID
Or use a named volume, the data will be found in Mountpoint
from inspect.
docker run --rm -v myclone:/clone IMAGE sleep 1
docker volume inspect myclone