Skip to content

Commit 41a9417

Browse files
committed
Added rename method
1 parent 3e1dded commit 41a9417

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

docker/client.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,23 @@ def remove_image(self, image, force=False, noprune=False):
892892
res = self._delete(self._url("/images/" + image), params=params)
893893
self._raise_for_status(res)
894894

895+
def rename(self, container, name):
896+
if isinstance(container, dict):
897+
container = container.get('Id')
898+
url = self._url("/containers/{0}/rename".format(container))
899+
params = {'name': name}
900+
res = self._post(url, None, params=params)
901+
self._raise_for_status(res)
902+
903+
def resize(self, container, height, width):
904+
if isinstance(container, dict):
905+
container = container.get('Id')
906+
907+
params = {'h': height, 'w': width}
908+
url = self._url("/containers/{0}/resize".format(container))
909+
res = self._post(url, params=params)
910+
self._raise_for_status(res)
911+
895912
def restart(self, container, timeout=10):
896913
if isinstance(container, dict):
897914
container = container.get('Id')
@@ -939,15 +956,6 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
939956
res = self._post_json(url, data=start_config)
940957
self._raise_for_status(res)
941958

942-
def resize(self, container, height, width):
943-
if isinstance(container, dict):
944-
container = container.get('Id')
945-
946-
params = {'h': height, 'w': width}
947-
url = self._url("/containers/{0}/resize".format(container))
948-
res = self._post(url, params=params)
949-
self._raise_for_status(res)
950-
951959
def stop(self, container, timeout=10):
952960
if isinstance(container, dict):
953961
container = container.get('Id')

docker/unixconn/unixconn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import six
15+
import requests.adapters
16+
import socket
1517

1618
if six.PY3:
1719
import http.client as httplib
1820
else:
1921
import httplib
20-
import requests.adapters
21-
import socket
2222

2323
try:
2424
import requests.packages.urllib3 as urllib3

0 commit comments

Comments
 (0)