Skip to content

Commit

Permalink
even closer to real docker compose command
Browse files Browse the repository at this point in the history
After more thorough investigation, tried to reproduced a closer behaviour to native docker compose CLI
  • Loading branch information
cplepage authored Jul 18, 2023
1 parent 5f3f2ae commit e9b8266
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,21 @@ async function up(docker, projectName, recipe, output) {
continue;
}
if (network.external === true) {
let returnedNetwork = await docker.listNetworks({
filters: { name: [ network.name || networkName ] },
const networkLookupName = network.name || networkName;

let returnedNetworks = await docker.listNetworks({
filters: { name: [ networkLookupName ] },
});

const externalNetwork = returnedNetworks.find(network => network.Name === networkLookupName)

if(!externalNetwork){
throw new Error(`network ${networkLookupName} declared as external, but could not be found`)
}

networks.push({
name: projectName + '_' + networkName,
network: await docker.getNetwork(returnedNetwork[0].Id),
network: await docker.getNetwork(externalNetwork.Id),
});
continue;
}
Expand Down

0 comments on commit e9b8266

Please sign in to comment.