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

feat: add support for remote docker over ssh #8349

Merged
merged 2 commits into from
Jan 23, 2023

Conversation

catusax
Copy link
Contributor

@catusax catusax commented Jan 22, 2023

Fixes: #5703

Description
this pr adds support for remote docker over ssh using connhelper package, the feat was introduced by docker cli by this commit: docker/cli#1014

TestCase

open google cloud shell:

https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://github.com/catusax/skaffold&cloudshell_git_branch=docker-ssh-support&cloudshell_open_in_editor=examples/cross-platform-builds/skaffold.yaml

# setup ssh
ssh-keygen
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
chmod 640 ~/.ssh/authorized_keys
sudo service ssh restart
ssh-copy-id 127.0.0.1
export DOCKER_HOST=ssh://127.0.0.1

# setup docker
export DOCKER_USER=<your dockerhub userid>
docker login -u $DOCKER_USER

export ROOT=$PWD && export PROJECT=$ROOT/examples/cross-platform-builds
cd $PROJECT

sed -i 's/skaffold-example/${DOCKER_USER}\/skaffold-example/g' skaffold.yaml
skaffold build # this will fail
# Cannot connect to the Docker daemon at ssh://127.0.0.1. Is the docker daemon running?. Docker build ran into internal error. Please retry.
# If this keeps happening, please open an issue..

# build new patch
cd $ROOT && LOCAL=true make 
sudo cp out/skaffold /usr/bin/skaffold

# build with ssh support
cd $PROJECT
skaffold build # success

# without ssh
unset DOCKER_HOST
skaffold build # success

@google-cla
Copy link

google-cla bot commented Jan 22, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@catusax
Copy link
Contributor Author

catusax commented Jan 23, 2023

sry for the unit test failure,i have fixed it

Copy link
Contributor

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catusax thank you very much for the PR here adding this feature and the detailed info you added here. Just tried it out, works great! LGTM!

@aaron-prindle aaron-prindle merged commit 97a1e7e into GoogleContainerTools:main Jan 23, 2023
@aran
Copy link
Contributor

aran commented Jul 31, 2024

Cross-referencing this issue here: #9484

Not sure if this is still working for you @catusax?

From a quick look at docs, it looks as if the latest Go docker client libraries may natively support ssh connections, so one path might be to remove this and upgrade the dependency.

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

Successfully merging this pull request may close these issues.

Skaffold does not work when using remote docker over ssh
3 participants