<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 '{print $1}') 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'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 "ssh tunnel" "docker tls public port" "ssh tunnel unix socket"</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='DOCKER_HOST=127.0.0.1:tunnelport docker'</code> and the rest is obvious.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传