With docker-py==1.10.2 trying to create service with networks settings fails with:
500 Server Error: Internal Server Error ("{"message":"json: cannot unmarshal string into Go value of type swarm.NetworkAttachmentConfig"}")
There is no documentation example how to handle it properly so i look for example in tests... Nothing.
Docker go sources defines NetworkAttachmentConfig like dict of two keys.
Docker-py documentation states for networks (list): List of network names or IDs to attach the service to. Default: None. which is false and untested.
Temporary walkaround:
Client.create_serivce(networks=[{'Target': 'some_network_name'}])
That's fair. I went by the description given here: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#create-a-service
But clearly this is incorrect.
Ow, I get it now... Totally misleading. It looks like every parameter need to be checked.
In TaskTemplate placement parameter suffers same situation.
500 Server Error: Internal Server Error ("{"message":"json: cannot unmarshal array into Go value of type swarm.Placement"}")
Docker go sources defines Placement like dict of one key with array of string.
Temporary walkaround:
Client.create_service(
task_template=TaskTeplate(
placement={
'Constraints': ['node.hostname==some_hostname']
}
)
)