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/
  • 相关阅读:
    luogu 1593
    luogu 1369
    hdu 1796
    bzoj 3398
    luogu 4587
    luogu 2152
    bzoj 3629
    bzoj 1507: [NOI2003]Editor
    bzoj 1503: [NOI2004]郁闷的出纳员
    bzoj 1497: [NOI2006]最大获利
  • 原文地址:https://www.cnblogs.com/leigepython/p/10638117.html
Copyright © 2011-2022 走看看