Docker-py: Client.create_service(networks=...) fails

Created on 14 Sep 2016  路  2Comments  路  Source: docker/docker-py

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'}])
groudocumentation kinbug

All 2 comments

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']
        }
    )
)
Was this page helpful?
0 / 5 - 0 ratings