docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Fix pulling with container create api

Open BeardedDonut opened this issue 5 years ago • 3 comments

Fix the pulling issue stated in #2635. Basically, similar to docker create it should pull the image if it does not exist locally.

BeardedDonut avatar Aug 08 '20 17:08 BeardedDonut

I would like to see the Python SDK and Docker CLI behavior in sync, so support this PR, but should point out that the current difference is documented: https://github.com/docker/docker-py/blob/b37a25d70b7d483cc0fbc78fb6863636ca84cbb3/docker/models/containers.py#L846-L858

This PR should at least update the documentation and ContainerCollection.run (which can call create twice). Then the maintainers can decide whether they want to change the documented behavior.

dan-hipschman avatar Sep 01 '20 18:09 dan-hipschman

@dan-hipschman-od Thanks for your comment, I just didn't get this part would you please clarify a bit.

This PR should at least update the documentation and ContainerCollection.run (which can call create twice). Then the maintainers can decide whether they want to change the documented behavior.

Thanks.

BeardedDonut avatar Sep 02 '20 04:09 BeardedDonut

Yea, I was just saying two things:

  • Could you update the documentation of ContainerCollection.create so it says it will try to pull the image if it doesn't exist locally?
  • And ContainerCollection.run currently calls create and assumes it will not pull the image, so run itself catches ImageNotFound and tries to pull the image (see below). Since you're changing create to pull the image, then run can be simplified: https://github.com/docker/docker-py/blob/b37a25d70b7d483cc0fbc78fb6863636ca84cbb3/docker/models/containers.py#L808-L814

dan-hipschman avatar Sep 02 '20 16:09 dan-hipschman