I'm trying to copy a number of files and folders to a docker image build from my localhost.
The files are like this:
folder1
file1
file2
folder2
file1
file2
I'm trying to make the copy like this:
COPY files/* /files/
However, all files are placed in /files/ is there a way in Docker to keep the subdirectory structure as well as copying the files into their directories?
This question is related to
copy
docker
dockerfile
Alternatively you can use a "." instead of *, as this will take all the files in the working directory, include the folders and subfolders:
FROM ubuntu
COPY . /
RUN ls -la /
If you want to copy a source directory entirely with the same directory structure, Then don't use a star(*). Write COPY command in Dockerfile as below.
COPY . destinatio-directory/
To merge a local directory into a directory within an image, do this. It will not delete files already present within the image. It will only add files that are present locally, overwriting the files in the image if a file of the same name already exists.
COPY ./files/. /files/
Source: Stackoverflow.com