Machine: docker-machine scp Permission denied

Created on 2 Jan 2016  路  10Comments  路  Source: docker/machine

I created a folder on a Docker machine (default) like this:

docker-machine ssh default -- mkdir -p /home/alexzeitler/src/myproject/subproject

Then I tried to copy local files from the current directory into it:

docker-machine scp -r . default:/home/alexzeitler/src/myproject/subproject

This results in:

scp: /home/alexzeitler/src/myproject/subproject/./config.json: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./node_modules: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./.gitignore: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./docker-compose.yml: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./api: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./app.js: Permission denied
aressh

Most helpful comment

In my case, this had to do with filesystem permissions on my boot2docker instance. I worked around it like so:

docker-machine scp -r myFolder/ machineName:/tmp
docker-machine ssh machineName sudo cp -r /tmp/myFolder /path/to/actual/destination

All 10 comments

I had to regenerate the certs (because of https://github.com/docker/machine/issues/1954 on Ubuntu as well) - might this cause the problem?

After re-creating the VM the issue is gone.

Regeneration of certs doesn't seem to cause it. Created another directory and tried to scp into it and it failed again.

Hi @AlexZeitler, can you tell us which version of docker-machine you are using and which OS you are on? Also if you are not using 0.5.5 of docker-machine, can you please try it?

@dgageot Thanks for your reply.
I'm running on Ubuntu 14.04 x64, docker-machine version 0.5.5, build 02c4254

This problem is incredibly limiting. I can't put a file on my docker machine!

In my case, this had to do with filesystem permissions on my boot2docker instance. I worked around it like so:

docker-machine scp -r myFolder/ machineName:/tmp
docker-machine ssh machineName sudo cp -r /tmp/myFolder /path/to/actual/destination

Is there a more elegant solution to this than the above? It works but seems counter to what you'd want to do.

wow, this is hacky...

The correct syntax for copying files to a machine is the following:
docker-machine scp path user@machine:path

So for example, it would be:
docker-machine scp ./src ubuntu@my-machine:~/dest

Don't forget the ~ to indicate that you are copying to your home folder. If you simply put /dest, it will not work because the user (in the above example ubuntu does not have permissions outside ~/.

Was this page helpful?
0 / 5 - 0 ratings