robbieperry22
robbieperry22

Reputation: 2245

Copy entire directory from docker container

Is it possible to copy an entire directory from a Docker image into a local directory? Normally when copying a file, I would do something like this:

docker cp <containerId>:/file/path/within/container /host/path/target

I've attempted to do the following, which does not work:

docker cp <containerId>:/file/path/within/container/* /host/path/target

Upvotes: 1

Views: 1667

Answers (1)

robbieperry22
robbieperry22

Reputation: 2245

As per @PraveenPremaratne's answer, my problem was using the wild card * to try and copy all the files. Instead the source should just be the directory name itself:

docker cp <containerId>:/file/path/within/container/srcDir /host/path/targetDir

Upvotes: 1

Related Questions