zoukankan      html  css  js  c++  java
  • docker数据拷贝

    docker数据拷贝

     

      docker数据拷贝的方式有很多种,下面介绍几种数据拷贝的方式;此处只是介绍几种简易的方式,更多方式可以google下。

      从容器中向主机拷贝数据

    docker cp <containerId>:/file/path/within/container /host/path/target 
    
    docker cp 8e7e5f4574f4:/root/test.txt ./test.txt

      从主机向容器中拷贝数据

    docker cp /host/path/target <containerId>:/file/path/within/container
    
    docker cp ./host.txt 8e7e5f4574f4:/root/host.txt

      用-v挂载主机数据卷到容器内

    docker run -v /path/to/hostdir:/mnt $container

      其余的在宿主机上操作即可

      通过输入输出符进行拷贝

    docker run -i ubuntu /bin/bash -c 'cat > /path/to/container/file' < /path/to/host/file/  
    
    # 或者
    
    docker exec -it <container_id> bash -c 'cat > /path/to/container/file' < /path/to/host/file/
  • 相关阅读:
    Daily Scrum 10.31
    Daily Scrum 10.30
    Daily Scrum 10.29
    Daily Scrum 10.28
    扩展设置
    安装
    james+javamail入门
    解决ZF2_PATH environment
    Apache Httpd Server 2.2升级2.4
    缓存,spring
  • 原文地址:https://www.cnblogs.com/leigepython/p/10638117.html
Copyright © 2011-2022 走看看