Copying files into and out of Kubernetes managed containers with kubectl cp


Kubectl has some pretty amazing features built in. One useful option is the ability to copy files into and out of containers. This functionality is provided through the cp command. To copy the file app.log from the container named myapp-4dpjr to the local directory you can use the following cp syntax:

$ kubectl cp myapp-4dpjr:/app/app.log .

To copy a file into a container you can reverse the cp arguments:

$ kubectl cp debugger myapp-4dpjr:/bin

In order to be able to copy a file into a container the tar executable needs to be installed. Cool stuff.

This article was posted by Matty on 2018-02-20 08:38:52 -0500 -0500