Skip to content

Commit

Permalink
Workround for Docker stripping docker.io
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Feb 4, 2024
1 parent 7c2a7d0 commit ee494ad
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions aiidalab_launch/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def _default_port() -> int: # explicit function required to enable test patchin
return DEFAULT_PORT


DEFAULT_IMAGE = "docker.io/aiidalab/full-stack:latest"
DEFAULT_REGISTRY = "docker.io"
DEFAULT_IMAGE_PATH = "aiidalab/full-stack:latest"
DEFAULT_IMAGE = f"{DEFAULT_IMAGE_REGISTRY}/{DEFAULT_IMAGE_PATH}"


def _valid_volume_name(source: str) -> None:
Expand All @@ -50,7 +52,7 @@ def _get_configured_host_port(container: Container) -> int | None:
host_config = container.attrs["HostConfig"]
return int(host_config["PortBindings"]["8888/tcp"][0]["HostPort"]) or None
except (KeyError, IndexError, ValueError):
raise
pass
return None


Expand Down Expand Up @@ -158,13 +160,14 @@ def from_container(cls, container: Container) -> Profile:

system_user = get_docker_env(container, "SYSTEM_USER")

print(container.image.tags)
image_tag = (
DEFAULT_IMAGE
if DEFAULT_IMAGE in container.image.tags
else container.image.tags[0]
)
print(f"{image_tag!r}")
if DEFAULT_IMAGE in container.image.tags:
image_tag = DEFAULT_IMAGE
# Docker seems to strip `docker.io` from the image name
# so we add it back manually.
elif DEFAULT_IMAGE_PATH in container.image.tags:
image_tag = f"{DEFAULT_REGISTRY}/{DEFAULT_IMAGE_PATH}"
else:
image_tag = container.image.tags[0]

extra_destinations: list[PurePosixPath] = [
PurePosixPath(mount["Destination"])
Expand All @@ -180,8 +183,6 @@ def from_container(cls, container: Container) -> Profile:
else:
extra_mounts.add(":".join([str(src), str(dst), "rw"]))

print(_get_configured_host_port(container))

return Profile(
name=profile_name,
port=_get_configured_host_port(container),
Expand Down

0 comments on commit ee494ad

Please sign in to comment.