-->

DEVOPSZONES

  • Recent blogs

    How to Copy Files from and to Kubernetes pods and Docker Container

    How to Copy Files from and to Kubernetes pods and Docker Container


    At times we need to send files from kbernetes nodes to kubernets pods for different use cases. Lets see how to do that. You can either copy files or whole folders.
    containers

    Copy Files from a pod to your machine


    kubectl cp {{namespace}}/{{podname}}:path/to/directory /local/path

    example:

    [root@ip-10-0-1-4 centos]# kubectl cp scdf-server-75b598cc56-b64hs:/root/scdfflowproject /home/centos                   

    Copy Files to a pod

    kubectl cp /local/path namespace/podname:path/to/directory

    example:
    [root@ip-10-0-1-4 centos]# kubectl cp gateway-service  scdf-server-75b598cc56-b64hs:/root/scdfflowproject/                   
    [root@ip-10-0-1-4 centos]# kubectl cp second-service  scdf-server-75b598cc56-b64hs:/root/scdfflowproject/


    Copy Files from a docker container to your machine

    docker cp containerID:/path/to/directory /local/path

    example:
    docker cp Prometheus0:/data /local/data

    Copy Files to a docker container

    docker cp /local/path containerID:path/to/directory

    example:
    docker cp /local/data Prometheus0:/data

    No comments