Repository: docker/docker-py

Issue:
Change container.short_id to 12 characters
The 12 character short id is used in quite a few places.

For example, the default alias for all containers in a network is their respective 12 character id.
The default representation in the cli is 12 character id.
The usual way to reference containers is by their 12 character id.

The current 10 digit short_id is quite meaningless and creates more confusion than help. Non of the usual uses for the short id will work with it.

Why not change it to 12?


Discussion:

Resolving patch:
diff --git a/docker/models/images.py b/docker/models/images.py
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -31,12 +31,12 @@ def labels(self):
     @property
     def short_id(self):
         """
-        The ID of the image truncated to 10 characters, plus the ``sha256:``
+        The ID of the image truncated to 12 characters, plus the ``sha256:``
         prefix.
         """
         if self.id.startswith('sha256:'):
-            return self.id[:17]
-        return self.id[:10]
+            return self.id[:19]
+        return self.id[:12]
 
     @property
     def tags(self):
@@ -141,10 +141,10 @@ def id(self):
     @property
     def short_id(self):
         """
-        The ID of the image truncated to 10 characters, plus the ``sha256:``
+        The ID of the image truncated to 12 characters, plus the ``sha256:``
         prefix.
         """
-        return self.id[:17]
+        return self.id[:19]
 
     def pull(self, platform=None):
         """
diff --git a/docker/models/resource.py b/docker/models/resource.py
--- a/docker/models/resource.py
+++ b/docker/models/resource.py
@@ -35,9 +35,9 @@ def id(self):
     @property
     def short_id(self):
         """
-        The ID of the object, truncated to 10 characters.
+        The ID of the object, truncated to 12 characters.
         """
-        return self.id[:10]
+        return self.id[:12]
 
     def reload(self):
         """


Test patch:
diff --git a/tests/unit/api_container_test.py b/tests/unit/api_container_test.py
--- a/tests/unit/api_container_test.py
+++ b/tests/unit/api_container_test.py
@@ -24,7 +24,8 @@ def test_start_container(self):
         self.client.start(fake_api.FAKE_CONTAINER_ID)
 
         args = fake_request.call_args
-        assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/start'
+        assert args[0][1] == (url_prefix + 'containers/' +
+                              fake_api.FAKE_CONTAINER_ID + '/start')
         assert 'data' not in args[1]
         assert args[1]['timeout'] == DEFAULT_TIMEOUT_SECONDS
 
@@ -117,7 +118,8 @@ def test_start_container_with_dict_instead_of_id(self):
         self.client.start({'Id': fake_api.FAKE_CONTAINER_ID})
 
         args = fake_request.call_args
-        assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/start'
+        assert args[0][1] == (url_prefix + 'containers/' +
+                              fake_api.FAKE_CONTAINER_ID + '/start')
         assert 'data' not in args[1]
         assert args[1]['timeout'] == DEFAULT_TIMEOUT_SECONDS
 
@@ -1079,7 +1081,8 @@ def test_resize_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/resize',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/resize'),
             params={'h': 15, 'w': 120},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1092,7 +1095,8 @@ def test_rename_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/rename',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/rename'),
             params={'name': 'foobar'},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1102,7 +1106,7 @@ def test_wait(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/wait',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/wait',
             timeout=None,
             params={}
         )
@@ -1112,7 +1116,7 @@ def test_wait_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/wait',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/wait',
             timeout=None,
             params={}
         )
@@ -1124,7 +1128,7 @@ def test_logs(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1140,7 +1144,7 @@ def test_logs_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1157,7 +1161,7 @@ def test_log_streaming(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1172,7 +1176,7 @@ def test_log_following(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1186,7 +1190,7 @@ def test_log_following_backwards(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1201,7 +1205,7 @@ def test_log_streaming_and_following(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1217,7 +1221,7 @@ def test_log_tail(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 10},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1233,7 +1237,7 @@ def test_log_since(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 'all', 'since': ts},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1250,7 +1254,7 @@ def test_log_since_with_datetime(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
                     'tail': 'all', 'since': ts},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1276,7 +1280,7 @@ def test_log_tty(self):
         assert m.called
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/logs',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/logs',
             params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
                     'tail': 'all'},
             timeout=DEFAULT_TIMEOUT_SECONDS,
@@ -1288,7 +1292,8 @@ def test_diff(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/changes',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/changes'),
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
 
@@ -1297,7 +1302,8 @@ def test_diff_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/changes',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/changes'),
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
 
@@ -1306,7 +1312,7 @@ def test_port(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/json',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/json',
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
 
@@ -1317,7 +1323,7 @@ def test_stop_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/stop',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stop',
             params={'t': timeout},
             timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
         )
@@ -1330,7 +1336,7 @@ def test_stop_container_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/stop',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stop',
             params={'t': timeout},
             timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
         )
@@ -1340,7 +1346,8 @@ def test_pause_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/pause',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/pause'),
             timeout=(DEFAULT_TIMEOUT_SECONDS)
         )
 
@@ -1349,7 +1356,8 @@ def test_unpause_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/unpause',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/unpause'),
             timeout=(DEFAULT_TIMEOUT_SECONDS)
         )
 
@@ -1358,7 +1366,7 @@ def test_kill_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/kill',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
             params={},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1368,7 +1376,7 @@ def test_kill_container_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/kill',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
             params={},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1378,7 +1386,7 @@ def test_kill_container_with_signal(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/kill',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/kill',
             params={'signal': signal.SIGTERM},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1388,7 +1396,8 @@ def test_restart_container(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/restart',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/restart'),
             params={'t': 2},
             timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
         )
@@ -1398,7 +1407,8 @@ def test_restart_container_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'containers/3cc2351ab11b/restart',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/restart'),
             params={'t': 2},
             timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
         )
@@ -1408,7 +1418,7 @@ def test_remove_container(self):
 
         fake_request.assert_called_with(
             'DELETE',
-            url_prefix + 'containers/3cc2351ab11b',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
             params={'v': False, 'link': False, 'force': False},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1418,7 +1428,7 @@ def test_remove_container_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'DELETE',
-            url_prefix + 'containers/3cc2351ab11b',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
             params={'v': False, 'link': False, 'force': False},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1428,7 +1438,8 @@ def test_export(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/export',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/export'),
             stream=True,
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1438,7 +1449,8 @@ def test_export_with_dict_instead_of_id(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/export',
+            (url_prefix + 'containers/' +
+             fake_api.FAKE_CONTAINER_ID + '/export'),
             stream=True,
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1448,7 +1460,7 @@ def test_inspect_container(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/json',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/json',
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
 
@@ -1464,7 +1476,7 @@ def test_container_stats(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/stats',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
             timeout=60,
             stream=True
         )
@@ -1474,7 +1486,7 @@ def test_container_top(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/top',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/top',
             params={},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1484,7 +1496,7 @@ def test_container_top_with_psargs(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'containers/3cc2351ab11b/top',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/top',
             params={'ps_args': 'waux'},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -1496,7 +1508,8 @@ def test_container_update(self):
             blkio_weight=345
         )
         args = fake_request.call_args
-        assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/update'
+        assert args[0][1] == (url_prefix + 'containers/' +
+                              fake_api.FAKE_CONTAINER_ID + '/update')
         assert json.loads(args[1]['data']) == {
             'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345
         }
diff --git a/tests/unit/api_image_test.py b/tests/unit/api_image_test.py
--- a/tests/unit/api_image_test.py
+++ b/tests/unit/api_image_test.py
@@ -100,7 +100,7 @@ def test_commit(self):
                 'repo': None,
                 'comment': None,
                 'tag': None,
-                'container': '3cc2351ab11b',
+                'container': fake_api.FAKE_CONTAINER_ID,
                 'author': None,
                 'changes': None
             },
@@ -112,7 +112,7 @@ def test_remove_image(self):
 
         fake_request.assert_called_with(
             'DELETE',
-            url_prefix + 'images/e9aa60c60128',
+            url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID,
             params={'force': False, 'noprune': False},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
@@ -287,7 +287,7 @@ def test_tag_image(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'images/e9aa60c60128/tag',
+            url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
             params={
                 'tag': None,
                 'repo': 'repo',
@@ -305,7 +305,7 @@ def test_tag_image_tag(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'images/e9aa60c60128/tag',
+            url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
             params={
                 'tag': 'tag',
                 'repo': 'repo',
@@ -320,7 +320,7 @@ def test_tag_image_force(self):
 
         fake_request.assert_called_with(
             'POST',
-            url_prefix + 'images/e9aa60c60128/tag',
+            url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/tag',
             params={
                 'tag': None,
                 'repo': 'repo',
@@ -334,7 +334,7 @@ def test_get_image(self):
 
         fake_request.assert_called_with(
             'GET',
-            url_prefix + 'images/e9aa60c60128/get',
+            url_prefix + 'images/' + fake_api.FAKE_IMAGE_ID + '/get',
             stream=True,
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py
--- a/tests/unit/api_test.py
+++ b/tests/unit/api_test.py
@@ -318,7 +318,7 @@ def test_remove_link(self):
 
         fake_request.assert_called_with(
             'DELETE',
-            url_prefix + 'containers/3cc2351ab11b',
+            url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID,
             params={'v': False, 'link': True, 'force': False},
             timeout=DEFAULT_TIMEOUT_SECONDS
         )
diff --git a/tests/unit/fake_api.py b/tests/unit/fake_api.py
--- a/tests/unit/fake_api.py
+++ b/tests/unit/fake_api.py
@@ -4,10 +4,10 @@
 
 CURRENT_VERSION = f'v{constants.DEFAULT_DOCKER_API_VERSION}'
 
-FAKE_CONTAINER_ID = '3cc2351ab11b'
-FAKE_IMAGE_ID = 'e9aa60c60128'
-FAKE_EXEC_ID = 'd5d177f121dc'
-FAKE_NETWORK_ID = '33fb6a3462b8'
+FAKE_CONTAINER_ID = '81cf499cc928ce3fedc250a080d2b9b978df20e4517304c45211e8a68b33e254'  # noqa: E501
+FAKE_IMAGE_ID = 'sha256:fe7a8fc91d3f17835cbb3b86a1c60287500ab01a53bc79c4497d09f07a3f0688'  # noqa: E501
+FAKE_EXEC_ID = 'b098ec855f10434b5c7c973c78484208223a83f663ddaefb0f02a242840cb1c7'  # noqa: E501
+FAKE_NETWORK_ID = '1999cfb42e414483841a125ade3c276c3cb80cb3269b14e339354ac63a31b02c'  # noqa: E501
 FAKE_IMAGE_NAME = 'test_image'
 FAKE_TARBALL_PATH = '/path/to/tarball'
 FAKE_REPO_NAME = 'repo'
@@ -546,56 +546,56 @@ def post_fake_secret():
     post_fake_import_image,
     f'{prefix}/{CURRENT_VERSION}/containers/json':
     get_fake_containers,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/start':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/start':
     post_fake_start_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/resize':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/resize':
     post_fake_resize_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/json':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/json':
     get_fake_inspect_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/rename':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/rename':
     post_fake_rename_container,
-    f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128/tag':
+    f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}/tag':
     post_fake_tag_image,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/wait':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/wait':
     get_fake_wait,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/logs':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/logs':
     get_fake_logs,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/changes':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/changes':
     get_fake_diff,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/export':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/export':
     get_fake_export,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/update':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/update':
     post_fake_update_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/exec':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/exec':
     post_fake_exec_create,
-    f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/start':
+    f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/start':
     post_fake_exec_start,
-    f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/json':
+    f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/json':
     get_fake_exec_inspect,
-    f'{prefix}/{CURRENT_VERSION}/exec/d5d177f121dc/resize':
+    f'{prefix}/{CURRENT_VERSION}/exec/{FAKE_EXEC_ID}/resize':
     post_fake_exec_resize,
 
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/stats':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/stats':
     get_fake_stats,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/top':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/top':
     get_fake_top,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/stop':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/stop':
     post_fake_stop_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/kill':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/kill':
     post_fake_kill_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/pause':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/pause':
     post_fake_pause_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/unpause':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/unpause':
     post_fake_unpause_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b/restart':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}/restart':
     post_fake_restart_container,
-    f'{prefix}/{CURRENT_VERSION}/containers/3cc2351ab11b':
+    f'{prefix}/{CURRENT_VERSION}/containers/{FAKE_CONTAINER_ID}':
     delete_fake_remove_container,
     f'{prefix}/{CURRENT_VERSION}/images/create':
     post_fake_image_create,
-    f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128':
+    f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}':
     delete_fake_remove_image,
-    f'{prefix}/{CURRENT_VERSION}/images/e9aa60c60128/get':
+    f'{prefix}/{CURRENT_VERSION}/images/{FAKE_IMAGE_ID}/get':
     get_fake_get_image,
     f'{prefix}/{CURRENT_VERSION}/images/load':
     post_fake_load_image,
diff --git a/tests/unit/models_containers_test.py b/tests/unit/models_containers_test.py
--- a/tests/unit/models_containers_test.py
+++ b/tests/unit/models_containers_test.py
@@ -377,6 +377,11 @@ def side_effect(*args, **kwargs):
 
 
 class ContainerTest(unittest.TestCase):
+    def test_short_id(self):
+        container = Container(attrs={'Id': '8497fe9244dd45cac543eb3c37d8605077'
+                                           '6800eebef1f3ec2ee111e8ccf12db6'})
+        assert container.short_id == '8497fe9244dd'
+
     def test_name(self):
         client = make_fake_client()
         container = client.containers.get(FAKE_CONTAINER_ID)
diff --git a/tests/unit/models_images_test.py b/tests/unit/models_images_test.py
--- a/tests/unit/models_images_test.py
+++ b/tests/unit/models_images_test.py
@@ -122,11 +122,11 @@ class ImageTest(unittest.TestCase):
     def test_short_id(self):
         image = Image(attrs={'Id': 'sha256:b6846070672ce4e8f1f91564ea6782bd675'
                                    'f69d65a6f73ef6262057ad0a15dcd'})
-        assert image.short_id == 'sha256:b684607067'
+        assert image.short_id == 'sha256:b6846070672c'
 
         image = Image(attrs={'Id': 'b6846070672ce4e8f1f91564ea6782bd675'
                                    'f69d65a6f73ef6262057ad0a15dcd'})
-        assert image.short_id == 'b684607067'
+        assert image.short_id == 'b6846070672c'
 
     def test_tags(self):
         image = Image(attrs={