简体   繁体   中英

Is it possible to copy data of bind mount destination to a local source folder?

I have Jenkins server running inside a docker container. It has mount section like this

"Mounts": [
    {
        "Type": "bind",
        "Source": "/mnt/data",
        "Destination": "/var/jenkins_home",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
    }
]

I see all the jenkins job configuration is present in /var/jenkins_home but even though it has source /mnt/data , I don't see the data there. It seems that the local source folder has been formatted. Now I want to get the data from /var/jenkins_home to the source directory /mnt/data . Could you please explain to me the commands to do it if it's possible?

I don't know why that bind mount does not work - just like you I would expect /mnt/data to be bound to/from the container's /var/jenkins_home . If the host directory was emtpy though it would be expectable that the container's mount is also empty initially.

You can use docker cp to copy files/folders between host and a docker container.

So for example docker cp jenkinscontainername:/var/jenkins_home./local_dir .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM