Skip to content

Can't create a service with multiple mounts  #1567

@niboo-ave

Description

@niboo-ave

Hellow again,
While I was attemptiong to create a service with multiples line, I find an error in the api code:
In the file /docker-2.2.1-py2.7.egg/docker/types/services.py
Line 110 and following we have :

            for mount in mounts:
                if isinstance(mount, six.string_types):
                    mounts.append(Mount.parse_mount_string(mount))
                    mounts.remove(mount)
            self['Mounts'] = mounts

Wich transform the required list ['/home/user1/:/mnt/vol2:rw', '/home/user2/:/mnt/vol3:rw', '/home/user3/:/mnt/vol4:rw']

into the list :
['/home/user2/:/mnt/vol3:rw', {'Source': '/home/user1/', 'ReadOnly': False, 'Type': 'bind', 'Target': '/mnt/vol2'}, {'Source': '/home/user3/', 'ReadOnly': False, 'Type': 'bind', 'Target': '/mnt/vol4'}]
Like you can see, the second element of my first list isn't parse into a dictionary.

The reason I found is because of the remove in the for each above.
After parse the first element of the list (index 0), it remove it. The second element goes to index 0 then end when the loop restart it goes the index 1. Then the second element is forgotten.
I will post a pull request

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions