Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when use docker cp. open : permission denied #564

Closed
snowc0de opened this issue Jan 18, 2019 · 16 comments
Closed

Error when use docker cp. open : permission denied #564

snowc0de opened this issue Jan 18, 2019 · 16 comments

Comments

@snowc0de
Copy link

Dear developers

I recently installed a Mediawiki app with this command

sudo docker run -d -p 12345:80 --name andrewiki mediawiki

That works perfectly but I loose my LocalSettings.php file (nessessary to change basic variables)
So I run this :
cd /home/gene/DBak/Andrew Bennett/
sudo docker cp andrewiki:/var/www/html/LocalSettings.php .
And there is the output :
open /home/gene/DBak/Andrew Bennett/LocalSettings.php: permission denied

I search elsewhere to find other issue like this one, but I didn't found anything pertinent. So I try :
sudo chown 777 daemon:daemon .
But nothing. The issue continue.

Please help me, if you find other way to have LocalSettings.php I will be very thanks.

Thanks in advance.

SudoBash

@mannharleen
Copy link

mannharleen commented Mar 13, 2019

same issue. anyone has any thoughts.
This happens when the docker user is non root. and when we perform docker cp, we sudo and try to copy into /home/.

Btw, it works when we do sudo docker cp x:y/z /root/

A workaround is to redirect stdout to a file on host filesystem:
sudo docker cp x:y/z - > logback.xml

@edward-agarwala
Copy link

I also have the same problem when the user is not root and sudo docker cp container:path/to/copy dest also works for me.

@FranzHuebner
Copy link

Same issue as @edward-agarwala and @mannharleen -> Temp. workaround for anyone stumbling upon this, is to copy the file to /tmp/ and move it from there.

@cpuguy83
Copy link
Collaborator

cpuguy83 commented Jul 1, 2019

Seems like a straight forward problem with permissions.
If your user doesn't have access to the directory then docker can't copy to it.

@FranzHuebner
Copy link

Hey @cpuguy83 I use copy in a dockerfile for the same folder and this works flawless. Nevertheless after executing the container and pulling the result with docker cp from bash, the error appears. Every command is done without root permissions.

@cpuguy83
Copy link
Collaborator

cpuguy83 commented Jul 1, 2019

The issue is not the container but the location you are copying to on the client side.

@cpuguy83
Copy link
Collaborator

cpuguy83 commented Jul 1, 2019

Closing since this doesn't really look like a docker issue.

@cpuguy83 cpuguy83 closed this as completed Jul 1, 2019
@MohamadHFallah
Copy link

Use sudo, ex : sudo docker cp 0e543d3f05:/home/crossTest /home

@ambatigan
Copy link

But using the 'sudo' is making the files to be with the owner as 'root', which is not good...
What else can be done to have the copied file as with non root user only?

@sim31
Copy link

sim31 commented Feb 12, 2020

I use sudo to execute this command and still get this error.

@ra0e
Copy link

ra0e commented Jul 30, 2020

Same here. Even using sudo does not slove the problem

@kurema
Copy link

kurema commented Oct 25, 2020

Same. sudo doesn't work. I can copy to /tmp but I can't see the result.
I found out that it's because I am using snap version.

$ which docker
/snap/bin/docker

In that case, copy it to /tmp and you will find it in /tmp/snap.docker/tmp.

@DanielYWoo
Copy link

this is NOT an issue of docker, this is an issue of snap. please report this problem to snap. @chopin2712

@robert-vonahi
Copy link

for me it ended up in /tmp/snap-private-tmp/snap.docker/tmp

@zhenye-tang
Copy link

for me it ended up in /tmp/snap-private-tmp/snap.docker/tmp

I'm the same, brother. Have you solved it on your end.

@StarsEnd33A2D17
Copy link

for me it ended up in /tmp/snap-private-tmp/snap.docker/tmp

I'm the same, brother. Have you solved it on your end.

It seems to be an issue with snap. I added the current user to the docker group and restarted docker using snap (disable, then enable), and everything was fine. (Prior to this, I had been using sudo docker)

Reference: snapcraft.io/docker

sudo snap disable docker
sudo snap enable docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests