Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - the container.create or run API does not pull ? #2635

Open
sumukhs opened this issue Aug 5, 2020 · 1 comment
Open

Question - the container.create or run API does not pull ? #2635

sumukhs opened this issue Aug 5, 2020 · 1 comment

Comments

@sumukhs
Copy link

sumukhs commented Aug 5, 2020

Based on the documentation, I expected that container create API would pull the image. However, I get a failure exception with ImageNotFound.

Is there a way to get the CLI behavior to pull if the image doesn't exist?

Thank you!

BeardedDonut added a commit to BeardedDonut/docker-py that referenced this issue Aug 8, 2020
Fix the pulling issue stated in docker#2635. Basically, similar to `docker
create` it should pull the image if it does not exist locally.
BeardedDonut added a commit to BeardedDonut/docker-py that referenced this issue Aug 8, 2020
Fix the pulling issue stated in docker#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>
BeardedDonut added a commit to BeardedDonut/docker-py that referenced this issue Aug 8, 2020
Fix the pulling issue stated in docker#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>
@dan-hipschman
Copy link

dan-hipschman commented Sep 1, 2020

Are you looking at the docker CLI documentation for docker create and assuming the Python SDK containers.create does the same thing? The Python SDK does document the ImageNotFound exception (although it's unclear from the docstring alone whether the exception is raised if the image doesn't exist at all, or just locally):

def create(self, image, command=None, **kwargs):
"""
Create a container without starting it. Similar to ``docker create``.
Takes the same arguments as :py:meth:`run`, except for ``stdout``,
``stderr``, and ``remove``.
Returns:
A :py:class:`Container` object.
Raises:
:py:class:`docker.errors.ImageNotFound`
If the specified image does not exist.

I agree it would be nice if they did the same thing though. That change might break existing usage that relies on the current behavior, but perhaps the maintainers would be open to it.

containers.run does pull the image if it's missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants