host snippets

How to access the host from a docker container

Tagged container, docker, host, ip  Languages bash

Access host from docker container IP:

# Mac
ping docker.for.mac.localhost

# Windows
ping docker.for.win.localhost

# Linux: use the hosts external IP, see:
# https://github.com/docker/for-linux/issues/264#issuecomment-385698947

Note that it’s not possible to use host networking on Mac or Windows, only Linux:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

See:

SSH jump host

Tagged host, jump, ssh  Languages bash
# Connect to server-b by going through server-a (you => server-a => server-b):
$ ssh -t <user>@<server-a> ssh <server-b>