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

Bug or Misleading Docu: All docker images will be downloaded when the image tag is not specified #2545

Closed
bonacci-johannes opened this issue Apr 8, 2020 · 3 comments · Fixed by #2671

Comments

@bonacci-johannes
Copy link

bonacci-johannes commented Apr 8, 2020

BUG
Setup: Python3.8: docker 4.2.0

When starting a clean postgres container using python docker sdk the docker sdk pulls all postgres images.

It would be helpful to update the docu mentioning that the version tag should be specified.
Or even more handy, introduce a default to the latest version?

Here is the code:

import docker
from docker.models.containers import Container
client = docker.from_env()
container: Container = client.containers.run(
    image='postgres', remove=True, auto_remove=True, detach=True,
    ports={'5432': '5432'},
    environment=
    [
        'POSTGRES_PASSWORD=pwd',
        'POSTGRES_USER=test',
        'POSTGRES_DB=test'
    ])

Bash output of 'docker images' before running the code:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

Bash output of 'docker images' after running the code:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
postgres            10.12               1fb929c54703        7 days ago          200MB
postgres            10-alpine           1bd67b33a51c        2 weeks ago         70.3MB
postgres            10.12-alpine        1bd67b33a51c        2 weeks ago         70.3MB
postgres            10.11               5fea18bb7e20        2 months ago        250MB
postgres            10.11-alpine        fb495265b81f        2 months ago        72.4MB
postgres            10.10-alpine        a071f71cc9bb        5 months ago        71.8MB
postgres            10.10               9a05a2b9e69f        5 months ago        211MB
postgres            10.2-alpine         400ef39e0dbf        2 years ago         39.5MB
...
...
...
@bonacci-johannes bonacci-johannes changed the title BUG: docker pulls all images even when image is specified delete me please Apr 8, 2020
@bonacci-johannes bonacci-johannes changed the title delete me please Bug or Misleading Docu: All docker images will be downloaded when the image tag is not specified Apr 8, 2020
@thaJeztah
Copy link
Member

defaulting to :latest would make sense, and would be in line with what the docker CLI does (https://github.com/docker/cli/blob/6deb4f1f634003188e8319b8266ccdc588651fb1/cli/command/image/pull.go#L56-L63), which requires the -a / --all-tags option to be set to pull all tags (note that for push the docker cli currently has the same behavior as is reported here, but this is changed in the upcoming release: moby/moby#40302

Usage:	docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

Options:
  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --platform string         Set platform if server is multi-platform capable
  -q, --quiet                   Suppress verbose output

@bonacci-johannes
Copy link
Author

defaulting to :latest would make sense, and would be in line with what the docker

Thanks for the response, this default behavior would improve the usability a lot.

@thaJeztah
Copy link
Member

I'm not sure if maintainers will get to making this change soon, but contributions are welcome if you're interested in making those changes

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

Successfully merging a pull request may close this issue.

2 participants