fix: Only join the default network when creating the container

We were joining every network on container creation, which is currently
bugged in Docker. We were also joining networks afterwards, so the
non-default networks are joined post-creation, and only the networkMode
container is joined on creation.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-09-24 12:02:41 +01:00
parent 06bbf9751a
commit 367dd876aa
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1
2 changed files with 6 additions and 4 deletions

View File

@ -114,8 +114,6 @@ module.exports = class ServiceManager extends EventEmitter
# TODO: Don't mutate service like this, use an interface
service.config.environment['RESIN_DEVICE_NAME_AT_INIT'] = deviceName
nets = service.extraNetworksToJoin()
@logger.logSystemEvent(logTypes.installService, { service })
@reportNewStatus(mockContainerId, service, 'Installing')

View File

@ -99,7 +99,6 @@ export class Service {
// We don't need this value
delete appConfig.commit;
// Get rid of any extra values and report them to the user
const config = sanitiseComposeConfig(appConfig);
@ -493,6 +492,11 @@ export class Service {
tmpFs[tmp] = '';
});
const mainNetwork = _.pickBy(
this.config.networks,
(_v, k) => k === this.config.networkMode,
) as ServiceConfig['networks'];
return {
Tty: this.config.tty,
Cmd: this.config.command,
@ -503,7 +507,7 @@ export class Service {
ExposedPorts: exposedPorts,
Image: this.config.image,
Labels: this.config.labels,
NetworkingConfig: ComposeUtils.serviceNetworksToDockerNetworks(this.config.networks),
NetworkingConfig: ComposeUtils.serviceNetworksToDockerNetworks(mainNetwork),
StopSignal: this.config.stopSignal,
Domainname: this.config.domainname,
Hostname: this.config.hostname,