docker-py
docker-py copied to clipboard
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.
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-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.
Yea, I was just saying two things:
- Could you update the documentation of
ContainerCollection.createso it says it will try to pull the image if it doesn't exist locally? - And
ContainerCollection.runcurrently callscreateand assumes it will not pull the image, sorunitself catchesImageNotFoundand tries to pull the image (see below). Since you're changingcreateto pull the image, thenruncan be simplified: https://github.com/docker/docker-py/blob/b37a25d70b7d483cc0fbc78fb6863636ca84cbb3/docker/models/containers.py#L808-L814