Skip to content

Commit

Permalink
Fix pulling with container create api
Browse files Browse the repository at this point in the history
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 <navid9675@gmail.com>
  • Loading branch information
BeardedDonut committed Aug 8, 2020
1 parent b4beaaa commit 2fc6a3d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docker/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,14 @@ def create(self, image, command=None, **kwargs):
kwargs['image'] = image
kwargs['command'] = command
kwargs['version'] = self.client.api._version
platform = kwargs.pop('platform', None)
create_kwargs = _create_container_args(kwargs)
resp = self.client.api.create_container(**create_kwargs)
try :
resp = self.client.api.create_container(**create_kwargs)
except ImageNotFound:
self.client.images.pull(image, platform=platform)
resp = self.client.api.create_container(**create_kwargs)

return self.get(resp['Id'])

def get(self, container_id):
Expand Down

0 comments on commit 2fc6a3d

Please sign in to comment.