[Noob needs help] using moby/moby over SSH in golang

xuanbao · · 448 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Is there a way for me to use the moby library to control containers on a remote host </p> <p>at the moment I am SSHing and running <code>docker exec -it $(docker ps | grep container-name | awk &#39;{print $1}&#39;) bash</code></p> <p>at the moment I am using go to use the aws api to find the IP address of the instance that has the container that I want and using <code>golang.org/x/crypto/ssh</code> for the actual SSHing but just running the above command on the host once I have done all that</p> <p>looking for a nicer way to handle this in code </p> <hr/>**评论:**<br/><br/>epiris: <pre><p>You could do this lots of ways depending on your constraints. The most correct would probably be to make the docker daemon listen on a public port over tls and use client certificate authentication. If you can&#39;t do this for some reason such as not being able to configure the remote docker service, you could easily setup a ssh reverse tunnel to forward traffic from a specific port to a local unix socket. You could also use ssh tunneling from the client side as well using your typical credentials. Google any of &#34;ssh tunnel&#34; &#34;docker tls public port&#34; &#34;ssh tunnel unix socket&#34;</p></pre>hipone: <pre><p>The easiest way is to start a ssh tunnel to your remote docker daemon, make an <code>alias remote-docker=&#39;DOCKER_HOST=127.0.0.1:tunnelport docker&#39;</code> and the rest is obvious.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

448 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传