toJson method
The JSON body of the create request.
Implementation
Map<String, Object?> toJson() => {
'Image': image,
if (environment.isNotEmpty)
'Env': [for (final e in environment.entries) '${e.key}=${e.value}'],
'Cmd': ?command,
'Entrypoint': ?entrypoint,
if (exposedPorts.isNotEmpty)
'ExposedPorts': {
for (final port in exposedPorts) '$port/tcp': <String, Object?>{},
},
if (labels.isNotEmpty) 'Labels': labels,
if (healthCheck case final check?)
'Healthcheck': {
'Test': check.test,
'Interval': check.interval.inMicroseconds * 1000,
'Timeout': check.timeout.inMicroseconds * 1000,
'Retries': check.retries,
},
'HostConfig': {
if (exposedPorts.isNotEmpty)
'PortBindings': {
for (final port in exposedPorts)
'$port/tcp': [
{'HostIp': publishIp, 'HostPort': ''},
],
},
if (binds.isNotEmpty) 'Binds': binds,
if (autoRemove) 'AutoRemove': true,
},
};