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       --insecure-skip-tls-verify=false      If true, the server's certificate
75       will not be checked for validity. This will make your HTTPS connections
76       insecure
77
78
79       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
80       quests.
81
82
83       --match-server-version=false        Require  server  version  to  match
84       client version
85
86
87       -n, --namespace=""      If present, the namespace scope  for  this  CLI
88       request
89
90
91       --password=""      Password for basic authentication to the API server
92
93
94       --profile="none"         Name   of   profile   to   capture.   One   of
95       (none|cpu|heap|goroutine|threadcreate|block|mutex)
96
97
98       --profile-output="profile.pprof"      Name of the  file  to  write  the
99       profile to
100
101
102       --request-timeout="0"       The length of time to wait before giving up
103       on a single server request. Non-zero values  should  contain  a  corre‐
104       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
105       out requests.
106
107
108       -s, --server=""      The address and port of the Kubernetes API server
109
110
111       --tls-server-name=""      Server name to  use  for  server  certificate
112       validation.  If  it  is  not provided, the hostname used to contact the
113       server is used
114
115
116       --token=""      Bearer token for authentication to the API server
117
118
119       --user=""      The name of the kubeconfig user to use
120
121
122       --username=""      Username for basic authentication to the API server
123
124
125       --version=false      Print version information and quit
126
127
128       --warnings-as-errors=false      Treat warnings received from the server
129       as errors and exit with a non-zero exit code
130
131
132

EXAMPLE

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

SEE ALSO

163       kubectl(1),
164
165
166

HISTORY

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