-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0f492e6
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:3.13 | ||
|
||
RUN apk add --no-cache --update openssh-client | ||
CMD ssh \ | ||
-o StrictHostKeyChecking=no \ | ||
-N ${TUNNEL_HOST} \ | ||
-L ${FORWARD_DSN} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SSH tunnel in Docker | ||
|
||
Use case: allow your Docker containers to use SSH tunnels | ||
to get into those hard to reach places like corporate resources, | ||
firewalled APIs etc. | ||
|
||
## Usage with Docker Compose | ||
|
||
```yaml | ||
services: | ||
# your reglar services | ||
|
||
ssh-tunnel: | ||
image: sigwinhq/ssh-tunnel:latest | ||
environment: | ||
# if the key is password-protected | ||
SSH_AUTH_SOCK: "/ssh-agent" | ||
# the host via which we tunnel | ||
TUNNEL_HOST: "[email protected]" | ||
# what do we want to proxy to? | ||
FORWARD_DSN: "*:443:firewalled-api.example.com:443" | ||
volumes: | ||
# your key is now usable by the tunnel | ||
- $HOME/.ssh:/root/ssh:ro | ||
# if the key is password-protected | ||
- $SSH_AUTH_SOCK:/ssh-agent | ||
# this part is to make the tunnel transparent to others | ||
networks: | ||
default: | ||
aliases: | ||
- firewalled-api.example.com | ||
``` | ||
After doing this, your other services should now have access | ||
to the firewalled API as if it's available directly, | ||
without even knowing about the proxy. |