Here is a quick list of the networking-related Docker command-line options, in case it helps you find the section below that you are looking for.
Some networking command-line options can only be supplied to the Docker server when it starts up, and cannot be changed once it is running:
-b BRIDGE
or --bridge=BRIDGE
-- see--bip=CIDR
-- see--default-gateway=IP_ADDRESS
-- seeHow Docker networks a container
--default-gateway-v6=IP_ADDRESS
-- see--fixed-cidr
-- see--fixed-cidr-v6
-- see-H SOCKET...
or --host=SOCKET...
--This might sound like it would affect container networking,
but it actually faces in the other direction:
it tells the Docker server over what channels
it should be willing to receive commands
like "run container" and "stop container."
--icc=true|false
-- seeCommunication between containers
--ip=IP_ADDRESS
-- see--ipv6=true|false
-- see--ip-forward=true|false
-- seeCommunication between containers and the wider world
--iptables=true|false
-- seeCommunication between containers
--mtu=BYTES
-- see--userland-proxy=true|false
-- seeThere are three networking options that can be supplied either at startup or when docker run
is invoked. When provided at startup, set the default value that docker run
will later use if the options are not specified:
--dns=IP_ADDRESS...
-- see--dns-search=DOMAIN...
-- see--dns-opt=OPTION...
-- seeFinally, several networking options can only be provided when calling docker run
because they specify something specific to one container:
-h HOSTNAME
or --hostname=HOSTNAME
-- seeConfiguring DNS and
How Docker networks a container
--link=CONTAINER_NAME_or_ID:ALIAS
-- seeConfiguring DNS and
Communication between containers
--net=bridge|none|container:NAME_or_ID|host
-- seeHow Docker networks a container
--mac-address=MACADDRESS...
-- seeHow Docker networks a container
-p SPEC
or --publish=SPEC
-- see-P
or --publish-all=true|false
-- seeTo supply networking options to the Docker server at startup, use the DOCKER_OPTS
variable in the Docker upstart configuration file. For Ubuntu, edit the variable in /etc/default/docker
or /etc/sysconfig/docker
for CentOS.
The following example illustrates how to configure Docker on Ubuntu to recognize a newly built bridge.
Edit the /etc/default/docker
file:
$ echo 'DOCKER_OPTS="-b=bridge0"' >> /etc/default/docker
Then restart the Docker server.
$ sudo service docker start
For additional information on bridges, see building your own bridge later on this page.