OC(1)

πŸ“¦
version 4.22.0 Β· 2 versions
, in nixpkgs unstable

πŸ¦‹ OC(1) β€” oc cp πŸ’…

okay so bestie, welcome to oc cp. this page is literally the copy-paste queen of the Openshift CLI β€” ported straight from the Kubernetes man-doc squad, June 2016, and she's still iconic. the oc manual name lives up top in the title so you don't forget where you are, and lowercase oc is the whole family (see the SEE ALSO down there, iykyk). let's get into it 🌸


✨ NAME ✨

oc cp β€” copy files and directories to and from containers 🫢

✨ SYNOPSIS ✨

oc cp [OPTIONS]

✨ DESCRIPTION ✨

copy files and directories to and from containers. periodt. that's the whole vibe β€” local stuff goes in, remote stuff comes out, and you don't have to think about it too hard πŸ’–


πŸŽ€ OPTIONS πŸŽ€

okay these are your own personal flags, no cap:

  • -c, --container="" β€” the container name, bestie. if you leave it out, it uses the kubectl.kubernetes.io/default-container annotation to pick which container to attach to β€” and if there's no annotation? it just grabs the first container in the pod. main character by default, lowkey.
  • --no-preserve=false β€” flip this and the copied file/directory's ownership and permissions will not be preserved in the container. so if you're like "i don't care about the perms, just give me the bytes," this is your girl 🧚
  • --retries=0 β€” how many times should we retry finishing a copy operation from a container? specify 0 to disable, or any negative value for infinite retrying (yes, forever β€” be so serious about it). default is 0, aka no retry at all. πŸ™ˆ

🌈 OPTIONS INHERITED FROM PARENT COMMANDS 🌈

these aren't even hers, she's just borrowing them from the parent command and she wears them gorgeously:

  • --as="" β€” username to impersonate for the operation. user could be a regular user or a service account in a namespace.
  • --as-group=[] β€” group to impersonate for the operation. this flag can be repeated to specify multiple groups.
  • --as-uid="" β€” UID to impersonate for the operation.
  • --as-user-extra=[] β€” user extras to impersonate for the operation. this flag can be repeated to specify multiple values for the same key.
  • --cache-dir="/homeless-shelter/.kube/cache" β€” default cache directory. yes that path is real, don't @ me πŸ’€
  • --certificate-authority="" β€” path to a cert file for the certificate authority.
  • --client-certificate="" β€” path to a client certificate file for TLS.
  • --client-key="" β€” path to a client key file for TLS.
  • --cluster="" β€” the name of the kubeconfig cluster to use.
  • --context="" β€” the name of the kubeconfig context to use.
  • --disable-compression=false β€” if true, opt-out of response compression for all requests to the server.
  • --insecure-skip-tls-verify=false β€” if true, the server's certificate will not be checked for validity. ⚠️ this will make your HTTPS connections insecure β€” read that again, bestie.
  • --kubeconfig="" β€” path to the kubeconfig file to use for CLI requests.
  • --kuberc="" β€” path to the kuberc file to use for preferences. this can be disabled by exporting KUBECTL_KUBERC=false feature gate or turning off the feature KUBERC=off.
  • --match-server-version=false β€” require server version to match client version.
  • -n, --namespace="" β€” if present, the namespace scope for this CLI request.
  • --profile="none" β€” name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex).
  • --profile-output="profile.pprof" β€” name of the file to write the profile to.
  • --request-timeout="0" β€” the length of time to wait before giving up on a single server request. non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). a value of zero means don't timeout requests.
  • -s, --server="" β€” the address and port of the Kubernetes API server.
  • --tls-server-name="" β€” server name to use for server certificate validation. if it is not provided, the hostname used to contact the server is used.
  • --token="" β€” bearer token for authentication to the API server.
  • --user="" β€” the name of the kubeconfig user to use.
  • --warnings-as-errors=false β€” treat warnings received from the server as errors and exit with a non-zero exit code.

πŸ’œ EXAMPLE πŸ’œ

here's the part where she eats, every single time. copy these verbatim, they're sacred πŸ•―οΈ

# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image.  If 'tar' is not present, 'oc cp' will fail.
#
# For advanced use cases, such as symlinks, wildcard expansion or
# file mode preservation, consider using 'oc exec'.

# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
tar cf - /tmp/foo | oc exec -i -n <some-namespace> <some-pod> -- tar xf - -C /tmp/bar

# Copy /tmp/foo from a remote pod to /tmp/bar locally
oc exec -n <some-namespace> <some-pod> -- tar cf - /tmp/foo | tar xf - -C /tmp/bar

# Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace
oc cp /tmp/foo_dir <some-pod>:/tmp/bar_dir

# Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
oc cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>

# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
oc cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar

# Copy /tmp/foo from a remote pod to /tmp/bar locally
oc cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar
⚠️ real talk though: that first note is !!!Important!!!. your container image needs the tar binary in it. if tar isn't there, oc cp will fail. no cap, no workaround, just vibes denied 😭

πŸ”₯ SEE ALSO πŸ”₯

  • oc(1), β€” the whole rest of the family, go say hi πŸ‘‘

πŸŽ€ HISTORY πŸŽ€

June 2016, ported from the Kubernetes man-doc generator. vintage, but she still slays ✨


okay that's the whole page, bestie β€” you're officially caught up πŸ’– Openshift / Openshift CLI User Manuals / OC(1), dated June 2016. go copy some files, you've got this πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from