Skip to main content

Using remote docker with SSH tunnel.

Project description

docker-tunnel is a console utility to use remote docker with SSH tunnel.

If you are using OS X or a Linux distribution with docker-unsupported kernel, no more running a virtual machine or ssh to a remote shell.

Installation

With pip:

$ pip install docker-tunnel

With pipsi (Recommended):

$ pipsi install docker-tunnel

Usage

$ docker-tunnel user@example.com
(user@example.com) $
(user@example.com) $ echo $DOCKER_HOST
127.0.0.1:4243
(user@example.com) $ docker ps  # go ahead
...
(user@example.com) $ ^D  # ctrl-d
$

More options:

$ docker-tunnel --help

Shell Theme Integration

Inside the tunnel injected shell, the environment variable DOCKER_HOST and DOCKER_PROMPT_INFO will be assigned. They can be used in your shell theme to prompt you which tunnel is using.

There is an example, my custom theme for OH-MY-ZSH.

Troubleshooting

Error response from daemon: client and server don't have same version (client : 1.14, server: 1.12)

The docker in source of CentOS 7 is using API 1.12 but the docker client in Homebrew of OS X is not. You can downgrade the docker client with Homebrew:

$ brew versions docker
...
1.0.0    git checkout c513c42 /usr/local/Library/Formula/docker.rb
...
$ cd /usr/local/Library/Formula  # now we install the old version of docker
$ git checkout c513c42 -- docker.rb
$ brew unlink docker
$ brew install docker
$ git checkout HEAD -- docker.rb
$ cd -
$ brew info docker  # check the installed versions and current version
...
/usr/local/Cellar/docker/1.1.1 (9 files, 9.8M) *
  Poured from bottle
/usr/local/Cellar/docker/1.2.0 (9 files, 6.6M)
  Poured from bottle
...
$ docker-tunnel user@example.com
(user@example.com) $ docker version
Client version: 1.0.0
Client API version: 1.12
...
(user@example.com) $ exit
$ brew switch 1.2.0  # restore to latest
bind: Address already in use. cannot listen to port: 4243

You can find out the process which held the 4243 port with sudo lsof -i :4243 and decide to kill it or pick another port with --local-port.

channel 1: open failed: connect failed: Connection refused. 2014/09/06 13:08:57 Get http://127.0.0.1:4243/v1.14/info: EOF

Does the docker server listen on 127.0.0.1:2375? You may have to set correct server info with --remote-host and --remote-port.

Known Bugs

  • The ssh tunnel can be authenticated with public key only. The password prompt will caused a crash.

Issues

If you want to report bugs or request features, please create issues on GitHub Issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker-tunnel-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

docker_tunnel-0.1.1-py2.py3-none-any.whl (6.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file docker-tunnel-0.1.1.tar.gz.

File metadata

File hashes

Hashes for docker-tunnel-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7abb9336e077bf856ecc02934db6e59b8f6c05eaaa64f2be732492e370ff5251
MD5 f21070b10514b517599efcb00280f3ac
BLAKE2b-256 0115ea343704e1462df9b3edd1f08b7f36ec27aa0b4a24fa992f2ea8949987c2

See more details on using hashes here.

File details

Details for the file docker_tunnel-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for docker_tunnel-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c3fdb9eba8f5d30dae848c4c01302d9f742fd850db1dd7e5be194b70ced1877c
MD5 cc5bca5593c02d8d165183cbc8e043f0
BLAKE2b-256 b47daf84e62a47a771db6f873d915154b02704d1f9c40361641ebcc3c1422e67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page