Giter Site home page Giter Site logo

docker-tunnel's Introduction

Working with remote docker daemon via a SSH tunel

Problem:

  • you don't have docker installed locally but have installed a client, that can talk to docker (e.g. your IDE)
  • you work on a thin client (e.g. your laptop) and want to access docker on a remote machine where you have 10x available resources

Solutions:

  • enable docker API (anybody can access your docker daemon and do pretty much what the root user can do)
  • enable docker API with TLS and a cert (research how it's done for your docker & distro version)
  • bind docker daemon's socket locally via SSH

Here we present the 3rd solution. This way the traffic is encrypted and we don't have to do any acrobatics around certs:

  1. On your server where docker daemon is running edit the file /lib/systemd/system/docker.service:

$ sudo nano /lib/systemd/system/docker.service

  1. Look for the line that starts with ExecStart which might look like:

ExecStart=/usr/bin/dockerd -H fd://

We'll add a TCP socket so we can bind it locally on our client via SSH: -H tcp://127.0.0.1:{choose_your_port_number}. The resulting line should look something like:

ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:{port_number_you've_decided_to_use}

  1. Reload your settings:

$ sudo systemctl daemon-reload && sudo service docker restart

  1. Bind the port from your client:

$ ssh pinky -nNT -L 19851:127.0.0.1:{port_number_you've_decided_to_use} &

Your should now be able to communicate with your remote docker via the TCP socket (http://127.0.0.1:{port_number_you've_decided_to_use}).

docker-tunnel's People

Contributors

jmakov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.