dockerode-compose will not work if docker-compose.yml file have small section networks:
version: "3"
services:
...
networks:
- any_net
networks:
any_net:
driver: "bridge"
ipam:
config:
- subnet: "172.143.0.0/16"
This configuration generates an error:
Error: (HTTP code 400) unexpected - invalid JSON: json: cannot unmarshal object into Go struct field IPAM.IPAM.Config of type []network.IPAMConfig
This is due to incorrect parameters being generated for docker.createNetwork() in the lib/network.js file
For example :
line 49:
var opts = {
Name: projectName + '_' + networkName,
Driver: network.driver,
DriverOpts: network.driver_opts, //unsetted in docker-compose.yml
Labels: {
...network.labels,
...{
'com.docker.compose.network': 'default',
'com.docker.compose.project': projectName,
},
},
Attachable: network.attachable, //may be unsetted in docker-compose.yml
EnableIPv6: network.enable_ipv6, //may be unsetted in docker-compose.yml
Internal: network.internal, //may be unsetted in docker-compose.yml
CheckDuplicate: true,
};
line 69
opts.IPAM = {
Driver: network.ipam.driver, //may be unsetted in docker-compose.yml
Options: network.ipam.options, //may be unsetted in docker-compose.yml
};
line 74
opts.IPAM['Config'] = {
Subnet: network.ipam.config.subnet, // network.ipam.config - its an array! .subnet may be unsetted
IPRange: network.ipam.config.ip_range, // network.ipam.config - its an array! .ip_range may be unsetted
Gateway: network.ipam.config.gateway, // network.ipam.config - its an array! .gateway may be unsetted
AuxAddress: network.ipam.config.aux_addresses, // network.ipam.config - its an array! .aux_addresses may be unsetted
};
For the correct parameters for creating a network with Dockerode, see the Docerode tests:
dockerode-compose will not work if
docker-compose.ymlfile have small sectionnetworks:This configuration generates an error:
This is due to incorrect parameters being generated for
docker.createNetwork()in thelib/network.jsfileFor example :
line 49:
line 69
line 74
For the correct parameters for creating a network with Dockerode, see the Docerode tests: