Skip to content

feat: add support for remote docker over ssh#8349

Merged
aaron-prindle merged 2 commits into
GoogleContainerTools:mainfrom
catusax:docker-ssh-support
Jan 23, 2023
Merged

feat: add support for remote docker over ssh#8349
aaron-prindle merged 2 commits into
GoogleContainerTools:mainfrom
catusax:docker-ssh-support

Conversation

@catusax

@catusax catusax commented Jan 22, 2023

Copy link
Copy Markdown
Contributor

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

google-cla Bot commented Jan 22, 2023

Copy link
Copy Markdown

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

catusax commented Jan 23, 2023

Copy link
Copy Markdown
Contributor Author

sry for the unit test failure,i have fixed it

@aaron-prindle aaron-prindle left a comment

Copy link
Copy Markdown
Contributor

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

aran commented Jul 31, 2024

Copy link
Copy Markdown
Contributor

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

3 participants