Skip to content

Commit b37a25d

Browse files
committed
Fix pulling with container create api
Fix the pulling issue stated in #2635. Basically, similar to `docker create` it should pull the image if it does not exist locally. Signed-off-by: Navid Ali Pour <[email protected]>
1 parent b4beaaa commit b37a25d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docker/models/containers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,14 @@ def create(self, image, command=None, **kwargs):
864864
kwargs['image'] = image
865865
kwargs['command'] = command
866866
kwargs['version'] = self.client.api._version
867+
platform = kwargs.pop('platform', None)
867868
create_kwargs = _create_container_args(kwargs)
868-
resp = self.client.api.create_container(**create_kwargs)
869+
try:
870+
resp = self.client.api.create_container(**create_kwargs)
871+
except ImageNotFound:
872+
self.client.images.pull(image, platform=platform)
873+
resp = self.client.api.create_container(**create_kwargs)
874+
869875
return self.get(resp['Id'])
870876

871877
def get(self, container_id):

0 commit comments

Comments
 (0)