1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl cp - Copy files and directories to and from containers
10
11
12

SYNOPSIS

14       kubectl cp [OPTIONS]
15
16
17

DESCRIPTION

19       Copy files and directories to and from containers.
20
21
22

OPTIONS

24       -c, --container=""      Container name. If omitted, use the kubectl.ku‐
25       bernetes.io/default-container annotation for selecting the container to
26       be attached or the first container in the pod will be chosen
27
28
29       --no-preserve=false      The copied file/directory's ownership and per‐
30       missions will not be preserved in the container
31
32
33       --retries=0      Set number of retries to  complete  a  copy  operation
34       from  a container. Specify 0 to disable or any negative value for infi‐
35       nite retrying. The default is 0 (no retry).
36
37
38

OPTIONS INHERITED FROM PARENT COMMANDS

40       --as=""      Username to impersonate for the operation. User could be a
41       regular user or a service account in a namespace.
42
43
44       --as-group=[]       Group  to  impersonate for the operation, this flag
45       can be repeated to specify multiple groups.
46
47
48       --as-uid=""      UID to impersonate for the operation.
49
50
51       --azure-container-registry-config=""      Path to the  file  containing
52       Azure container registry configuration information.
53
54
55       --cache-dir="/builddir/.kube/cache"      Default cache directory
56
57
58       --certificate-authority=""      Path to a cert file for the certificate
59       authority
60
61
62       --client-certificate=""      Path to a client certificate file for TLS
63
64
65       --client-key=""      Path to a client key file for TLS
66
67
68       --cluster=""      The name of the kubeconfig cluster to use
69
70
71       --context=""      The name of the kubeconfig context to use
72
73
74       --disable-compression=false      If true, opt-out of response  compres‐
75       sion for all requests to the server
76
77
78       --insecure-skip-tls-verify=false      If true, the server's certificate
79       will not be checked for validity. This will make your HTTPS connections
80       insecure
81
82
83       --kubeconfig=""       Path  to  the  kubeconfig file to use for CLI re‐
84       quests.
85
86
87       --match-server-version=false       Require  server  version  to   match
88       client version
89
90
91       -n,  --namespace=""       If  present, the namespace scope for this CLI
92       request
93
94
95       --password=""      Password for basic authentication to the API server
96
97
98       --profile="none"        Name   of   profile   to   capture.   One    of
99       (none|cpu|heap|goroutine|threadcreate|block|mutex)
100
101
102       --profile-output="profile.pprof"       Name  of  the  file to write the
103       profile to
104
105
106       --request-timeout="0"      The length of time to wait before giving  up
107       on  a  single  server  request. Non-zero values should contain a corre‐
108       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
109       out requests.
110
111
112       -s, --server=""      The address and port of the Kubernetes API server
113
114
115       --tls-server-name=""       Server  name  to  use for server certificate
116       validation. If it is not provided, the hostname  used  to  contact  the
117       server is used
118
119
120       --token=""      Bearer token for authentication to the API server
121
122
123       --user=""      The name of the kubeconfig user to use
124
125
126       --username=""      Username for basic authentication to the API server
127
128
129       --version=false      Print version information and quit
130
131
132       --warnings-as-errors=false      Treat warnings received from the server
133       as errors and exit with a non-zero exit code
134
135
136

EXAMPLE

138                # !!!Important Note!!!
139                # Requires that the 'tar' binary is present in your container
140                # image.  If 'tar' is not present, 'kubectl cp' will fail.
141                #
142                # For advanced use cases, such as symlinks, wildcard expansion or
143                # file mode preservation, consider using 'kubectl exec'.
144
145                # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
146                tar cf - /tmp/foo | kubectl exec -i -n <some-namespace> <some-pod> -- tar xf - -C /tmp/bar
147
148                # Copy /tmp/foo from a remote pod to /tmp/bar locally
149                kubectl exec -n <some-namespace> <some-pod> -- tar cf - /tmp/foo | tar xf - -C /tmp/bar
150
151                # Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace
152                kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
153
154                # Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
155                kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
156
157                # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
158                kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
159
160                # Copy /tmp/foo from a remote pod to /tmp/bar locally
161                kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar
162
163
164
165

SEE ALSO

167       kubectl(1),
168
169
170

HISTORY

172       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
173       com)  based  on the kubernetes source material, but hopefully they have
174       been automatically generated since!
175
176
177
178Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum