Networking
When deploying applications multiple network configurations are available (container to container and container to host services)
By default, all container in the application can communicate with each other based on their container names, for example:
In this case, Metabase application can connect to Postgres database via postgres:5432
.
Customizing network
Network mode is configured within individual container specification:
Bridge network mode (default)
If no networkMode
is provided container will be sharing default
bridge for all containers:
If multiple containers are provided within application specification and bridge network is provided - containers will share networking.
When using bridge networking with multiple containers custom hostname
can be provided from applications to reach other containers. This is very useful when application need to communicate with other container, without exposing it.
For short names use option hostname
. In the example bellow container hello-synpse-redis-go
will be able to reach redis
by calling http://redis:port
Host network mode
host
network mode will make containers use the same network as the device itself. This is useful when your application needs to connect to a server that's running on the device itself or a container that is on another Docker network.
By running multiple containers on the same device there is chance for port clashes.
DNS
Individual containers DNS names can be specified with parameter hostname
Port Mapping
Containers can expose ports to device by using port mapping configuration. It allows direct mapping or port translation.
Last updated