28

I'm trying to copy an entire directory from my docker image to my local machine.

The image is a keycloak image, and I'd like to copy the themes folder so I can work on a custom theme.

I am running the following command -

docker cp 143v73628670f:keycloak/themes ~/Development/Code/Git/keycloak-recognition-login-branding

However I am getting the following response -

Error response from daemon: Could not find the file keycloak/themes in container 143v73628670f

When I connect to my container using -

 docker exec -t -i 143v73628670f /bin/bash

I can navigate to the themes by using -

cd keycloak/themes/

I can see it is located there and the files are as expected in the terminal.

I'm running the instance locally on a Mac.

How do I copy that entire themes folder to my local machine? What am I doing wrong please?

Harry Blue
  • 4,202
  • 10
  • 39
  • 78
  • 1
    [Docker - copy file from container to host](https://stackoverflow.com/q/22049212/6521116) – LF00 Nov 17 '17 at 05:58

1 Answers1

37

EDIT

As a result of running 'pwd' your should run the Docker cp command as follows:

docker cp 143v73628670f:/opt/jboss/keycloak/themes ~/Development/Code/Git/keycloak-recognition-login-branding

You are forgetting the trailing ' / '. Therefore your command should look like this:

docker cp 143v73628670f:/keycloak/themes/ ~/Development/Code/Git/keycloak-recognition-login-branding

Also, you could make use of Docker volumes, which allows you to pass a local directory into the container when you run the container

Sergiu
  • 2,928
  • 3
  • 27
  • 37