Docker Community Forums

Share and learn in the Docker community.

COPY root directory of docker context as folder not just its contents


(Simontheleg) #1

Hey guys,

I was wondering if its possible to somehow copy over the root directory of the docker context as a directory itself and not only its contents?

A little bit of Background why I want to make it so complicated
I am trying to use this whole thing in a Parent-Child relationship with many slightly different children where the parent contains an ONBUILD trigger to tell the child to copy over its root directory like this, while it needs to retain the individual name of the root directory:

Parent-Dockerfile


ONBUILD COPY [ideally root directory of the child itself] /someNiceLocation/

But because of the aforementioned restriction and because I do not know the childs root folder name in the parent as it changes from child to child, I cannot simply take the content of the child’s root directory and re-create the name (or at least I couldn’t figure out how to do it), like so:

Parent-Dockerfile


ONBUILD COPY ./ /someNiceLocation/[re-created root directory name of the child itself]