Docker/Networking: Difference between revisions
From charlesreid1
| Line 27: | Line 27: | ||
Stunnel forwards traffic on to 127.0.0.1 port 22. This port needs to be bound, somehow, to somewhere. Keep it simple: bind container port 22 (internal) to host port 22 (external) using <code>-p 22:22</code> when executing docker run. | Stunnel forwards traffic on to 127.0.0.1 port 22. This port needs to be bound, somehow, to somewhere. Keep it simple: bind container port 22 (internal) to host port 22 (external) using <code>-p 22:22</code> when executing docker run. | ||
Now the container should be started up, and stunnel should be run from within the container: | |||
<pre> | |||
$ ./run_docker.sh | |||
root@localhost# stunnel | |||
... | |||
root@localhost# | |||
</pre> | |||
==Network Equals Host Flag== | ==Network Equals Host Flag== | ||
Note that you can also configure the container to share networks with the host, by adding <code>--network=host</code> when executing docker run. | Note that you can also configure the container to share networks with the host, by adding <code>--network=host</code> when executing docker run. | ||
Revision as of 23:28, 30 March 2017
Setting up networking between containers and host.
Stunnel
Stunnel networking configuration:
The stunnel server is running in a Docker container. Here is the stunnel server configuration file:
# server config, # stunnel server will listen for stunnel clients connecting on port 443 # traffic will be decrypted and forwarded to local port 22 output = /var/log/stunnel4/stunnel.log cert = /etc/stunnel/stunnel.fullchain.pem key = /etc/stunnel/stunnel.key.pem pid = /var/run/stunnel4/stunnel.pid client = no [ssh] accept = 443 connect = 127.0.0.1:22
Note this is the same as is in the d-stunnel repo on git.charlesreid1.com: https://charlesreid1.com:3000/docker/d-stunnel
Stunnel server listens on port 443 (internal). This is mapped to port 443 (external) on the host using the -p 443:443 flag when executing docker run.
Stunnel forwards traffic on to 127.0.0.1 port 22. This port needs to be bound, somehow, to somewhere. Keep it simple: bind container port 22 (internal) to host port 22 (external) using -p 22:22 when executing docker run.
Now the container should be started up, and stunnel should be run from within the container:
$ ./run_docker.sh root@localhost# stunnel ... root@localhost#
Network Equals Host Flag
Note that you can also configure the container to share networks with the host, by adding --network=host when executing docker run.