Skip to content

Commit

Permalink
Prefix the container hash with sha256:
Browse files Browse the repository at this point in the history
The new docker version no longers supports building from just the hash, it must
be prefixed with sha256: or the image will not be found.
  • Loading branch information
dcermak committed Aug 7, 2023
1 parent b49a15b commit 6905a06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pytest_container/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def __post_init__(self) -> None:

def __str__(self) -> str:
return (
self.container_id
f"sha256:{self.container_id}"
or f"container derived from {self.base.__str__()}"
)

Expand Down Expand Up @@ -690,7 +690,7 @@ def prepare_container(
self.base
if isinstance(self.base, str)
else getattr(self.base, "url", self.base.container_id)
or self.base.container_id
or f"sha256:{self.base.container_id}"
)
assert from_id
containerfile_contents = f"""FROM {from_id}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_inspect(container: ContainerData):
assert (
"HOME" in inspect.config.env and inspect.config.env["HOME"] == "/src/"
)
assert inspect.config.image == str(container.container)
assert f"sha256:{inspect.config.image}" == str(container.container)
assert inspect.config.cmd == ["/bin/sh"]

assert (
Expand Down

0 comments on commit 6905a06

Please sign in to comment.