machine icon indicating copy to clipboard operation
machine copied to clipboard

windows7 sp1 > docker-machine scp doesn't work: exit status 1 (usage)

Open boly38 opened this issue 9 years ago • 15 comments

Hi I'm trying to do some basics: scp a given file onto a fresh new docker instance.

I don't understand what's wrong. I'm under windows 7 SP1 / windows git bash. (I was trying the same under cmd.exe with same result)

Here is the step to reproduce for me using git bash:


$ export PATH=/c/Programmes/DockerToolbox/:/c/Programmes/Git/bin/:/c/Programmes/Git/usr/bin/

$ git --version
git version 2.15.0.windows.1

$ docker-machine version
docker-machine.exe version 0.13.0, build 9ba6da9

$ /c/Programmes/VirtualBox/VBoxManage.exe --version
5.2.0r118431

$ cd /c/tempo

$ docker-machine create default
# it works!
# (...)
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Programmes\DockerToolbox\docker-machine.exe env default


$ docker-machine.exe ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v17.10.0-ce

$ eval "$(docker-machine env default)"

$ docker-machine.exe ssh default
# it works!

$ echo SimpleFile > myFile

$ docker-machine scp myFile default:
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
exit status 1

What is really confusing is that when I'm doing the same stuff with debug mode, docker-machine is providing the command used. And this one works!

$ docker-machine --debug scp myFile default:
Docker Machine Version:  0.13.0, build 9ba6da9
Found binary path at C:\Programmes\DockerToolbox\docker-machine.exe
Launching plugin server for driver virtualbox
Plugin server listening at address 127.0.0.1:59450
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(default) Calling .GetSSHPort
(default) Calling .GetSSHKeyPath
(default) Calling .GetSSHKeyPath
(default) Calling .GetSSHKeyPath
(default) Calling .GetSSHHostname
(default) Calling .GetSSHUsername
{C:\Programmes\Git\usr\bin\scp.exe [C:\Programmes\Git\usr\bin\scp.exe -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -3 -o IdentitiesOnly=yes -o Port=59393 -o IdentityFile="C:\\Users\\myuserhere\\.docker\\machine\\machines\\default\\id_rsa" myFile [email protected]:] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> <nil> false [] [] [] [] <nil> <nil>}
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
exit status 1


$ C:\\Programmes\\Git\\usr\\bin\\scp.exe -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -3 -o IdentitiesOnly=yes -o Port=59393 -o IdentityFile="C:\\Users\\myuserhere\\.docker\\machine\\machines\\default\\id_rsa" myFile [email protected]:
myFile                                                 100%   11     6.3KB/s   00:00        
# it works!

The only diff is the "\" in the binary path ("\\" expected)

After reading some close issue, I got same status with the following attempt:

$ MYSYS_NO_PATHCONV=1 docker-machine scp localhost:./myFile default:/home/docker
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
exit status 1

do you know how to fix that ?

boly38 avatar Nov 03 '17 12:11 boly38

Here is a workaround I'm using:

MACHINE=default

echo "Loading env for $MACHINE docker machine"
eval $(docker-machine env $MACHINE) || (echo "Unable to set machine $MACHINE env" && exit 1)


function alternate_scp {
	echo "Hum... seems 'docker-machine scp' doesn't work, try alternate way.."
	# retrieve docker default machine SSH PORT
	# cat ~/.docker/machine/machines/default/default/default.vbox|grep Forwarding
	# using grep regexp to isolate forwarded port number only
	SSHPORT=`cat ~/.docker/machine/machines/$MACHINE/$MACHINE/$MACHINE.vbox|grep Forwarding| grep -oP "hostport=\"\K\d+"`
	echo " - retrieved ssh forwarded port: $SSHPORT"
	# using generated pk
	SSHIDFILE=~/.docker/machine/machines/$MACHINE/id_rsa
	echo " - using identity: $SSHIDFILE"

	SSHOPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -3 -o IdentitiesOnly=yes "
	scp.exe $SSHOPTS -o Port=$SSHPORT -o IdentityFile="$SSHIDFILE" -r resources [email protected]: || (echo "Unable to scp machine $MACHINE" && exit 1)
}

echo "Copy resources"
docker-machine scp -r resources $MACHINE: || alternate_scp

boly38 avatar Nov 03 '17 14:11 boly38

@boly38 I met the same issue on Windows 10. It might be related to #4261. When using v0.12.2, docker-machine scp myFile default: works fine.

matt9ucci avatar Nov 03 '17 16:11 matt9ucci

thanks @matt9ucci another people met the same issue with 0.13.0. Seems to be related to this version. I confirm that older version doesn't produce this error.

boly38 avatar Nov 14 '17 11:11 boly38

This is a major regression -- no one looking at this?

drnybble avatar Jan 03 '18 16:01 drnybble

yeah, I can confirm that on docker-machine.exe version 0.13.0, build 9ba6da9 going to the linux docker-host via git bash on a windows 10 machine, that scp is not working and returns "exit status 1"

if I run the debug command directly, taking out the space from the scp pathing and only run scp.exe blah blah blah, it works.

pageflex avatar Jan 17 '18 20:01 pageflex

I have the same issue, I have even tried to install older Docker Toolbox version (the one that should come with docker-machine 0.12.2) but it seems that it somehow installs newest docker-machine 0.13.0

Please fix this!

pidzama avatar Jan 18 '18 13:01 pidzama

@pidzama If you run it with a --debug, it will give you the eventual call that it's trying to make to the machine. Run THAT on a command line (minus the full path to scp) and the command itself worked for me.

pageflex avatar Jan 18 '18 13:01 pageflex

I've ran into this same issue, though it doesn't seem to matter if there is spacing in the path to scp.exe. I installed Git with no spacing in the install path and still ran into this issue.

Running the call copied from --debug works as stated above.

Win 10, docker-machine 0.13.0, Git 2.16.0.2x64

kblooie avatar Jan 22 '18 18:01 kblooie

Friendly bump for this issue. Upgraded from 17.09 to 17.12 (Windows 10 Professional) and ran into this problem. Worked before.

Using Git Bash:

$ docker-machine --version docker-machine.exe version 0.13.0, build 9ba6da9 $ docker-machine create --driver virtualbox --virtualbox-hostonly-cidr 192.168.99.99/24 --virtualbox-cpu-count 1 --virtualbox-memory 1024 --virtualbox-no-share docker-vm $ docker-machine scp foo.txt docker-vm:/home/docker/foo.txt usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2 exit status 1

Uninstalling Docker, (re-)installing 17.09

$ docker-machine --version docker-machine.exe version 0.12.2, build 9371605 $ docker-machine create --driver virtualbox --virtualbox-hostonly-cidr 192.168.99.99/24 --virtualbox-cpu-count 1 --virtualbox-memory 1024 --virtualbox-no-share docker-vm $ docker-machine scp foo.txt docker-vm:/home/docker/foo.txt foo.txt (100% progressbar)

Sadface.

j-koehler avatar Jan 24 '18 11:01 j-koehler

Just installed the latest version of Docker Toolbox and ran in to the same proble. Doing a --debug will give me the right command to call.

We use docker-machine scp as a step in our automated developer setup, and this will not work until this bug is fixed.

bechhansen avatar Feb 07 '18 10:02 bechhansen

@thaJeztah Anyone available to get attention on this regression?

drnybble avatar Feb 07 '18 13:02 drnybble

@bechhansen here is a workaround: https://github.com/docker/machine/issues/4302#issuecomment-341727432

we implemented this in our local build environment. might (or might not) work for you as well.

j-koehler avatar Feb 07 '18 13:02 j-koehler

ping @shin-

thaJeztah avatar Feb 08 '18 00:02 thaJeztah

I'm guessing this is somehow related to golang/go#17149 but it's quite mysterious that using the exact command present in the debug output works when pasted directly into the shell.

shin- avatar Feb 08 '18 01:02 shin-

See https://github.com/docker/machine/pull/4388, this will now be fixed in 0.14.0

pageflex avatar Mar 01 '18 21:03 pageflex