Skip to content

Commit

Permalink
fix: Raise error when a created docker container exposes no port (#1645)
Browse files Browse the repository at this point in the history
Backported-from: main
Backported-to: 23.03
  • Loading branch information
fregataa authored and achimnol committed Oct 23, 2023
1 parent 464c5d0 commit 8c269b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/1645.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle `None` value of newly created Docker container's port.
5 changes: 4 additions & 1 deletion src/ai/backend/agent/docker/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,10 @@ async def start_container(
if container_config["HostConfig"].get("NetworkMode") == "host":
host_port = host_ports[idx]
else:
host_port = int((await container.port(port))[0]["HostPort"])
ports: list[dict[str, Any]] | None = await container.port(port)
if ports is None:
raise ContainerCreationError(container_id=cid)
host_port = int(ports[0]["HostPort"])
assert host_port == host_ports[idx]
if port == 2000: # intrinsic
repl_in_port = host_port
Expand Down

0 comments on commit 8c269b9

Please sign in to comment.