johanhaleby / docker-machine-port-forwarder

Simple bash script that makes it easier to forward ports from Docker Machine
Apache License 2.0
109 stars 21 forks source link

When I'm running under root, I've got the error #7

Open iworker opened 5 years ago

iworker commented 5 years ago

When I'm running under root, I've got the error:

sudo pf 443
machine does not exist

It seems, sudo can't see the docker-machine. So, I'm usually solving the problem just connecting to docker-machine: docker-machine ssh default in one tab. In the other tab, I'm searching for the running process: ps aux | grep ssh. I've got something like that:

ivan             44949   0.0  0.1  4279248   5708 s003  S+    7:06PM   0:00.04 /usr/bin/ssh -F /dev/null -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none -o LogLevel=quiet -o PasswordAuthentication=no -o ServerAliveInterval=60 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker@127.0.0.1 -o IdentitiesOnly=yes -i /Users/ivan/.docker/machine/machines/default/id_rsa -p 51651

Then I'm running the same command under root, but I'm adding -f -N -L 443:localhost:443:

sudo /usr/bin/ssh -F /dev/null -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none -o LogLevel=quiet -o PasswordAuthentication=no -o ServerAliveInterval=60 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker@127.0.0.1 -o IdentitiesOnly=yes -i /Users/ivan/.docker/machine/machines/default/id_rsa -p 51651 -f -N -L 443:localhost:443

It would be nice if there will be the working solution in the script. Thanks ;)

johanhaleby commented 5 years ago

Can we do this and still be backward compatible?