Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
blog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
blog
Commits
1b4c9ddf
Commit
1b4c9ddf
authored
7 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Added post on forwarding the Docker socket with SSH.
parent
80c12624
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
content/docker_socket_over_ssh.rst
+29
-0
29 additions, 0 deletions
content/docker_socket_over_ssh.rst
with
29 additions
and
0 deletions
content/docker_socket_over_ssh.rst
0 → 100644
+
29
−
0
View file @
1b4c9ddf
Docker socket over SSH
######################
:date: 2018-01-09
:summary: Docker socket over SSH
Yesterday I described how to connect to a remote :code:`dockerd` over TCP. I
didn't touch security considerations at all (firewall, TLS certificate). This
because, for my use, I prefer a different method, forwarding the Unix socket
over SSH. Here's how.
First, you need OpenSSH version 6.7 or later (both client and server). Also,
the login user on the remote instance must have permissions to access the Docker
socket (in other words, be a member of the :code:`docker` group).
Here's how to forward the remote socket:
.. code:: shell
ssh -fNTo ExitOnForwardFailure=yes -o ServerAliveInterval=30 -L $HOME/.ssh/docker.sock:/var/run/docker.sock host
export DOCKER_HOST=$HOME/.ssh/docker.sock
And to close the connection and return to the local :code:`dockerd` kill the
:code:`ssh` process that's running in the background, :code:`rm` the docker
socket under :code:`$HOME/.ssh` and unset :code:`DOCKER_HOST`.
The reason I prefer this method is that it's easier to setup for ad-hoc tasks
and arguably more secure since you not only authenticate the user and host with
SSH, but you limit access to only those that are part of the :code:`docker`
group.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment