Re: [kubernetes/kubernetes] Kubectl cp gives "tar: removing leading '/' from member names" warning (#58692)

4,328 views
Skip to first unread message

Erick Fejta

unread,
Jan 28, 2018, 1:09:49 AM1/28/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@kubernetes/sig-cli-feature-requests


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Jesse Almanrode

unread,
Jan 31, 2018, 4:53:56 PM1/31/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Something I found is that if I do not put a / at the beginning of my path following : in <pod>:<path> that the kubectl cp command works fine.

Stephan Westen

unread,
Feb 1, 2018, 9:07:38 AM2/1/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

I tried your suggestion to drop the leading slash like this:

kubectl cp cms-sw-one-6bf986b657-65vbn:home/cms/tomcat/logs ~/documents -c cms --namespace=od'

This gives the following error:

stderr: tar: home/cms/tomcat/logs: Cannot stat: No such file or directory

With the leading / it works fine except for the warning.

Konstantin Chugalinskiy

unread,
Mar 12, 2018, 6:31:09 AM3/12/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

You may try to copy your files to workdir and then retry to copy them using just their names. It's weird, but it works for now.

Yonatan Bitton

unread,
Apr 11, 2018, 9:39:04 AM4/11/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

I have the same problem, to solve this, I used the advice @kchugalinskiy gave.

I moved the wanted file to the working dir in the pod (the directory which is automatically opened, when you open bash on it) -

user@podname:/usr/src# ls data.txt
data.txt

In my case it is - /usr/src folder.

Then in my local bash terminal -

user@local:~$ kubectl cp podname:data.txt data.txt
user@local:~$ ls data.txt
data.txt

Matt McKellar-Spence

unread,
Apr 27, 2018, 1:28:40 AM4/27/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

I'm receiving the same error message, but also finding the file copied correctly from the container to my local machine.

  • Client: v1.10.1
  • Server: v1.9.4-gke.1
  • Platform: GKE

I'm not sure where to add the tar -C flag when using kubectl cp.

Suraj Deshmukh

unread,
Jun 9, 2018, 6:23:44 AM6/9/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention
$ ll
total 0

$ kubectl cp web-6fc578559d-sns6p:/usr/share/httpd/noindex/index.html ./new
tar: Removing leading `/' from member names

$ echo $?
0

$ cat new | head -10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
                <title>Apache HTTP Server Test Page powered by CentOS</title>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!-- Bootstrap -->
    <link href="/noindex/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="noindex/css/open-sans.css" type="text/css" />

<style type="text/css"><!-- 

it's not an error some condition since the exit code is 0. Also the functionality works fine, it's just the error which comes which is kinda confusing.

And this is anwered in multiple places on stackoverflow, https://stackoverflow.com/a/25929424 and https://unix.stackexchange.com/a/59244

TonyAdo

unread,
Jun 10, 2018, 8:20:07 AM6/10/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

I would think this is not a bug, it's just what we expect and should not break any functionality.

AnthonyWC

unread,
Sep 30, 2018, 11:46:25 PM9/30/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

It works fine but the message is just confusing.

fejta-bot

unread,
Dec 29, 2018, 11:16:41 PM12/29/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

fejta-bot

unread,
Jan 29, 2019, 12:00:42 AM1/29/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.

/lifecycle rotten

fejta-bot

unread,
Feb 28, 2019, 12:19:15 AM2/28/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.


Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Kubernetes Prow Robot

unread,
Feb 28, 2019, 12:19:24 AM2/28/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Kubernetes Prow Robot

unread,
Feb 28, 2019, 12:19:29 AM2/28/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Closed #58692.

Tuan Anh Tran

unread,
Apr 2, 2019, 12:45:06 AM4/2/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

i cannot copy the file anywhere else. permission issue.

is there another workaround?

Suraj Deshmukh

unread,
Apr 4, 2019, 3:21:47 AM4/4/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@tuananh can you please provide the steps you are performing and what errors do you see? Please elaborate on what you are trying to achieve?

Tuan Anh Tran

unread,
Apr 4, 2019, 3:24:31 AM4/4/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@surajssd im trying to get redis dump from container to my machine using this command

kubectl cp dev/redisdev-master-0:/bitnami/redis/data/dump.rdb ~/dump.rdb

I'm getting the above error

tar: Removing leading `/' from member names

Suraj Deshmukh

unread,
Apr 4, 2019, 3:30:16 AM4/4/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@tuananh was the file copied successfully if yes then this is not really an error. If not then there could be other issues. See #58692 (comment) for more info

Tuan Anh Tran

unread,
Apr 4, 2019, 3:51:38 AM4/4/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention
my bad. the file was copied indeed.



On Thu, Apr 4, 2019 at 2:30 PM Suraj Deshmukh <notifi...@github.com>
wrote:

> @tuananh <https://github.com/tuananh> was the file copied successfully if

> yes then this is not really an error. If not then there could be other
> issues. See #58692 (comment)
> <https://github.com/kubernetes/kubernetes/issues/58692#issuecomment-395957776>
> for more info
>
> —
> You are receiving this because you were mentioned.

> Reply to this email directly, view it on GitHub
> <https://github.com/kubernetes/kubernetes/issues/58692#issuecomment-479783189>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAmSTp5rOGSyz1ZITvuuRI6Dg-zWYvjIks5vdaoGgaJpZM4Rppzx>
> .

ushell

unread,
Sep 27, 2019, 4:57:21 AM9/27/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

The error reason is kubectl cp not use right pod file path.

example:

Pod WORKDIR set '/var/www/html'

if you want copy /var/www/html/foo.log to your location file folder

you will run kubectl cp POD_NAME:foo.log /Users/foo/foo.log , it work ok,

if run kubectl cp POD_NAME:/var/www/html/foo.log /Users/foo/foo.log will get warning.

Allen

unread,
Jan 1, 2020, 9:28:13 PM1/1/20
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

When i in c: run
kubectl cp backend-68c49589fb-7dkkm:/fileStorage/20191231/cd28206c5e654390a815cc03bbc6d14e.png d:/xxx.jpg


error:
tar: Removing leading `/' from member names

remove the / after pod: like

kubectl cp backend-68c49589fb-7dkkm:fileStorage/20191231/cd28206c5e654390a815cc03bbc6d14e.png d:/xxx.jpg
it's ok.


You are receiving this because you are on a team that was mentioned.

Reply to this email directly, view it on GitHub, or unsubscribe.

Eivind

unread,
Jan 8, 2020, 4:13:43 AM1/8/20
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@wangrqsh The issue has nothing to do with the drives on your local Windows computer. The latter works for you because the WORKDIR in your pod is /. Try setting a different WORKDIR in your pod, and you will also experience the warning.

balibebas

unread,
Jan 10, 2021, 2:52:49 AM1/10/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Saw the message trying to copy files out of a Pod. Didn't think to actually check the file system until I saw the suggestion from @AnthonyWC:

It works fine but the message is just confusing.

Looks like the message is just a warning that isn't squelched. Probably.

Daniel

unread,
Mar 10, 2021, 10:42:37 PM3/10/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

this should probably be reopened

Kael

unread,
Mar 23, 2021, 6:49:43 AM3/23/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

this should probably be reopened

Yes, this should probably be reopened

@fejta-bot is evil.

Erhhung Yuan

unread,
Apr 2, 2021, 6:52:19 PM4/2/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Why this issue should be closed solely because it's not a serious bug or error is baffling. It is obviously a very real and annoying issue of usability given how many people have complained about it. Asking people to copy/move the file into the WORKDIR first is not a solution—I could just as easily ignore the warning in the first place.

If an output message is confusing and serves no informational purpose to the user, then it should be suppressed by default—asking the operator to > /dev/null is not a solution, either.

Daniel

unread,
Apr 2, 2021, 8:21:06 PM4/2/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Preach brother

On Fri, Apr 2, 2021 at 3:52 PM Erhhung Yuan ***@***.***>
wrote:


> Why this issue should be closed solely because it's not a serious bug or
> error is baffling. It is obviously a *very real and annoying issue of
> usability* given how many people have complained about it. Asking people

> to copy/move the file into the WORKDIR first is not a solution—I could
> just as easily ignore the warning in the first place.
>
> If an output message is confusing and *serves no informational purpose*

> to the user, then it should be suppressed by default—asking the operator to >
> /dev/null is not a solution, either.
>
> —
> You are receiving this because you commented.

> Reply to this email directly, view it on GitHub
> <https://github.com/kubernetes/kubernetes/issues/58692#issuecomment-812745674>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABSSN2W7WVUY2JIOPYRBLCDTGZDCDANCNFSM4ENGTTYQ>
> .
>
--
Daniel Yakobian
Case Western Reserve University - Comp Sci

Shubham Joshi

unread,
May 10, 2021, 11:42:57 PM5/10/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Hi ! I want to pick this up. Can suppress the warning which is very concussing for the users.

Shubham Joshi

unread,
May 10, 2021, 11:43:13 PM5/10/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

/reopen

Kubernetes Prow Robot

unread,
May 10, 2021, 11:43:25 PM5/10/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@joshi95: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

shemerk

unread,
Oct 25, 2023, 8:18:10 AM10/25/23
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

I have this exact same issue.
what I found was the repeatedly executing the command eventually works (like 1 success out of 5-10 failures)
it's weird, probably has to due with the enveloping Linux environment, and to make matters worse: when the command DO work, it doesn't actually create the copied file anywhere....

I eventually gave up and simply copy-pasted the file's content


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are on a team that was mentioned.Message ID: <kubernetes/kubernetes/issues/58692/1779146391@github.com>

luckychengww

unread,
Aug 21, 2024, 2:11:38 AM8/21/24
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

you can use command like this to avoid "tar: removing leading '/' from member names)" error

kubectl exec -c ${containerPod} -n ${namespace} ${podName} -- sh -c "cd /data/ && tar cf - config.yml" | tar xf - -C /home/ubuntu/


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are on a team that was mentioned.Message ID: <kubernetes/kubernetes/issues/58692/2301208345@github.com>

Emrah Becer

unread,
Jan 10, 2025, 11:20:29 AMJan 10
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

As a workaround, I piped the output to sed and removed this useless message.

| sed -r "s/tar: removing leading '/' from member names//"

I don't want to suppress all output. It can contain useful messages but I just don't want to see this one. Especially if you write a bash script, it floods your screen.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are on a team that was mentioned.Message ID: <kubernetes/kubernetes/issues/58692/2583144083@github.com>

Reply all
Reply to author
Forward
0 new messages