Remove a volume. Similar to the ``docker volume rm`` command. Args: name (str): The volume's name force (bool): Force removal of volumes that were already removed out of band by the volume driver plugin. Raises: :py:class
(self, name, force=False)
| 138 | return self._result(self._post(url, params=params), True) |
| 139 | |
| 140 | def remove_volume(self, name, force=False): |
| 141 | """ |
| 142 | Remove a volume. Similar to the ``docker volume rm`` command. |
| 143 | |
| 144 | Args: |
| 145 | name (str): The volume's name |
| 146 | force (bool): Force removal of volumes that were already removed |
| 147 | out of band by the volume driver plugin. |
| 148 | |
| 149 | Raises: |
| 150 | :py:class:`docker.errors.APIError` |
| 151 | If volume failed to remove. |
| 152 | """ |
| 153 | params = {} |
| 154 | if force: |
| 155 | if utils.version_lt(self._version, '1.25'): |
| 156 | raise errors.InvalidVersion( |
| 157 | 'force removal was introduced in API 1.25' |
| 158 | ) |
| 159 | params = {'force': force} |
| 160 | |
| 161 | url = self._url('/volumes/{0}', name, params=params) |
| 162 | resp = self._delete(url) |
| 163 | self._raise_for_status(resp) |