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

Different SHA 256 Digest when using CLI and SDK #2773

Closed
mikemhenry opened this issue Feb 19, 2021 · 2 comments
Closed

Different SHA 256 Digest when using CLI and SDK #2773

mikemhenry opened this issue Feb 19, 2021 · 2 comments

Comments

@mikemhenry
Copy link

mikemhenry commented Feb 19, 2021

I get two different sha256 digests when pulling docker.io/library/alpine:latest

When using CLI I get
sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be

When using the SDK I get
sha256:28f6e27057430ed2a40dbdd50d2736a3f0a295924016e294938110eeb8439818

I thought it may be related to: docker/hub-feedback#1925

But when I try and pull the image reported by the SDK I get:

$ docker pull docker.io/library/alpine@sha256:28f6e27057430ed2a40dbdd50d2736a3f0a295924016e294938110eeb8439818
Error response from daemon: received unexpected HTTP status: 500 Internal Server Error

So I am unable to inspect the potential differences with the CLI.

Steps to reproduce:

CLI

docker pull docker.io/library/alpine:latest
latest: Pulling from library/alpine
Digest: sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be
Status: Image is up to date for alpine:latest
docker.io/library/alpine:latest

SDK

>>> import docker
>>> client = docker.from_env()
>>> container = client.images.pull("docker.io/library/alpine", tag="latest")
>>> container.id
'sha256:28f6e27057430ed2a40dbdd50d2736a3f0a295924016e294938110eeb8439818'

OS, python, docker info:

$ pip freeze | grep docker && python --version && docker version
docker==4.4.3
Python 3.8.6
Client:
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.8
 Git commit:        4484c46
 Built:             Fri Dec 18 12:00:51 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.8
  Git commit:       4484c46
  Built:            Fri Dec  4 23:02:49 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7-0ubuntu3.2
  GitCommit:        
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit: 
$ cat /etc/os-release
NAME="Pop!_OS"
VERSION="20.10"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 20.10"
VERSION_ID="20.10"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy
LOGO=distributor-logo-pop-os
@feliperuhland
Copy link
Contributor

Hi @mikemhenry

The object that returns from client.images.pull("docker.io/library/alpine", tag="latest") is an Image Object and the id attribute is from the image.

To get the digest hash you have to access the attrs dict and get the RepoDigests key.

>>> image = cli.images.pull("docker.io/library/alpine", tag="latest")
>>> image
<Image: 'alpine:latest'>
>>> image.attrs.get("RepoDigests")
['alpine@sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be']

@mikemhenry
Copy link
Author

Thank you very much! Sorry for the superfluous issue.

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