Docker (software): Difference between revisions

Line 60: Line 60:
** To restrict listing to localhost use <code>-p 127.0.0.1:80:80</code>
** To restrict listing to localhost use <code>-p 127.0.0.1:80:80</code>
* <code>-it</code> to be interactive with a pseudo-tty
* <code>-it</code> to be interactive with a pseudo-tty
==Networking==
The default mode for networking is bridge. You should leave this for most of your containers.
===bridge===
In bridge mode, the docker service acts as a NAT and gives each container a separate local IP along with the docker host. 
On linux, you can type <code>ip a</code> to see the ip address of the <code>docker0</code> network interface. 
On my server, it is <code>172.17.0.1/16</code>. 
To access services running on the host (such as MySQL or Postgres), you will need to make these services liston on this network interface and allow it through your firewall. 
Then make your docker containers connect using the ip address of your docker host.
===host===
In this mode, docker processes have full access to your network. This can cause port conflicts if you are not careful.
Furthermore, your docker service will have full access to your localhost. I do not recommend using this mode for most things.


==Windows==
==Windows==