Size: 917
Comment:
|
Size: 1479
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
Furthermore, the default network's use of IPv6 mandatorily matches the `dockerd(8)` configuration. See [[Docker/Configuration#IPv6|here]] to enable it. | Furthermore, the default network's use of [[Protocols/IP|IPv6]] mandatorily matches the `dockerd(8)` configuration. See [[Docker/Configuration#IPv6|here]] to enable it. |
Line 23: | Line 23: |
== Creating Networks == | == Custom Networks == |
Line 25: | Line 25: |
Custom bridge network can be created and destroyed like: | Custom bridge networks can be created and destroyed like: |
Line 32: | Line 32: |
A container can be created on a network by specifying the `--network` option. | A container can be created on a custom network by specifying the `--network` option. |
Line 35: | Line 35: |
docker run --detach --name my-nginx \ --network=my-net \ nginx:latest |
|
Line 36: | Line 39: |
Containers on a custom bridge network can communicate with each other by addressing the containers' names. For example, the above container would be accessible at `http://my-nginx`. {{{ $ docker run --interactive --tty --name my-alpine \ --network=my-net \ alpine:latest # apk add curl [ ... ] # curl http://my-nginx <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> [ ... ] }}} Note that ''all'' ports are exposed. |
Docker Bridge Networks
Bridge networks are a type of networks used by dockerd(8).
Default Network
By default, containers attach to bridge networks. See here to change that.
If a bridge network is not specified, the default network is used. This network is special in that there is no name resolution; the only way to communicate between containers is their ephemeral IP addresses.
Furthermore, the default network's use of IPv6 mandatorily matches the dockerd(8) configuration. See here to enable it.
Custom Networks
Custom bridge networks can be created and destroyed like:
docker network create my-net docker network rm my-net
A container can be created on a custom network by specifying the --network option.
docker run --detach --name my-nginx \ --network=my-net \ nginx:latest
Containers on a custom bridge network can communicate with each other by addressing the containers' names. For example, the above container would be accessible at http://my-nginx.
$ docker run --interactive --tty --name my-alpine \ --network=my-net \ alpine:latest # apk add curl [ ... ] # curl http://my-nginx <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> [ ... ]
Note that all ports are exposed.