Skip to content

Commit 1865765

Browse files
committed
network.type support added
Signed-off-by: scicco <zendar79@gmail.com>
1 parent 69adaa1 commit 1865765

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scompose/project/instance.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def network_args(self):
221221
"""
222222
return self.params.get("network", {}).get("args", [])
223223

224-
def _get_network_commands(self, ip_address=None):
224+
def _get_network_commands(self, ip_address=None, network_type=None):
225225
"""
226226
Take a list of ports, return the list of --network-args to
227227
ensure they are bound correctly.
@@ -236,7 +236,11 @@ def _get_network_commands(self, ip_address=None):
236236
for arg in network_args:
237237
ports += ["--network-args", arg]
238238

239-
if not network_args and (not self.sudo and not fakeroot):
239+
if network_type is not None
240+
# network_type is "bridge" by default when network.enable is True
241+
ports += ["--network", network_type]
242+
243+
if network_type is None and (not self.sudo and not fakeroot):
240244
ports += ["--network", "none"]
241245

242246
for pair in self.ports:
@@ -604,7 +608,10 @@ def create(self, ip_address=None, sudo=False, writable_tmpfs=False):
604608

605609
# Network configuration + Ports
606610
if self.network["enable"]:
607-
options += self._get_network_commands(ip_address)
611+
# if network.enable is true a --network must be always added
612+
# using bridge as default
613+
network_type = self.network["type"] or "bridge"
614+
options += self._get_network_commands(ip_address, network_type)
608615

609616
# Start options
610617
options += self.start_opts

0 commit comments

Comments
 (0)