How to copy the docker container folders to local

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

How to copy the docker container folders to local

Hi,

I am trying to copy the alfresco related folders to local from the docker container(usr/local/tomcat ).

Is there a better way to do that?

5 Replies
Highlighted
Moderator
Moderator

Re: How to copy the docker container folders to local

If i understand correctly that you want to keep the copy of folders on host, you can use bind mounts to do that. It will automatically create specified folders and keep the folders up to date with containers. 

Here is an example of docker-compose services, read my comments in highlighted part:

version: '2'
services:
  acs62-aio-demo-project-share:
    image: alfresco-share-acs62-aio-demo-project:development
    mem_limit: 1g
    .....
....... volumes: #Bind mount SHORT SYNTAX - [SOURCE:]TARGET[:MODE] #SOURCE can be a named volume or a (relative or absolute) path on the host system. #TARGET is an absolute path in the container where the volume is mounted. #MODE is a mount option which can be read-only (ro) or read-write (rw) (default). - ../../../logs/share:/usr/local/tomcat/logs acs62-aio-demo-project-acs: image: alfresco-content-services-acs62-aio-demo-project:development mem_limit: 1700m ...
..... volumes: #Bind mount SHORT SYNTAX - [SOURCE:]TARGET[:MODE] #SOURCE can be a named volume or a (relative or absolute) path on the host system. #TARGET is an absolute path in the container where the volume is mounted. #MODE is a mount option which can be read-only (ro) or read-write (rw) (default). - ../../../data/alfresco/alf_data:/usr/local/tomcat/alf_data - ../../../logs/alfresco:/usr/local/tomcat/logs

......
......

 

 

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)
Highlighted
Member II

Re: How to copy the docker container folders to local

Thank you Abhinav. If someone already ran the images is there is any option to copy the entire alfresco folder structure to our local system .

docker cp alfresco_1:/usr/local/tomcat <destination>

the above command copy only  the amps folders and not the webapps or shared folders.

Highlighted
Advanced

Re: How to copy the docker container folders to local

As  said you can try to map /usr/local/tomcat folder inside the container to a directory in the host ,like following.
Then you an do whatever you want
volumes:
            - /your host folder:/usr/local/tomcat

Highlighted
Moderator
Moderator

Re: How to copy the docker container folders to local

yes but note that, if you are using windows host, tomcat startup script may fail to start as it will try to execute ".sh" script. I have not tried but most likely error is expected on windos host.

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)
Highlighted
Senior Member

Re: How to copy the docker container folders to local

My thorts it is some permisions or storage problem.

sudo docker cp alfresco_1:/usr/local/tomcat <local_folder>

must copy all folders and files from '/usr/local/tomcat' including mapped persistant volume alf_data.

 

Go to your containre and check the folders you try to copy:

sudo docker exec -it alfresco_1 bash
cd /usr/local/tomcat
ls -la

 

Try copy folder by folder

sudo docker cp alfresco_1:/usr/local/tomcat/shared <local_folder/shared>
sudo docker cp alfresco_1:/usr/local/tomcat/webapps <local_folder/webapps>

and get some errors.

 

p.s. docker is natural linux. dont use wondows.