Skip to content

Commit

Permalink
fix: container commit not working on Docker 23 (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyujin-cho committed Apr 22, 2024
1 parent ee3cda3 commit f08911e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/2040.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix container commit not working on certain docker engine versions
21 changes: 17 additions & 4 deletions src/ai/backend/agent/docker/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,23 @@ def _write_chunks(
async with FileLock(path=lock_path, timeout=0.1, remove_when_unlock=True):
log.info("Container (k: {}) is being committed", kernel_id)
docker = Docker()
container = docker.containers.container(container_id)
changes: list[str] = []
for label_name, label_value in extra_labels.items():
changes.append(f"LABEL {label_name}={label_value}")
try:
# There is a known issue at certain versions of Docker Engine
# which prevents container from being committed when request config body is empty
# https://github.com/moby/moby/issues/45543
docker_info = await docker.system.info()
docker_version = docker_info["ServerVersion"]
major, _, patch = docker_version.split(".", maxsplit=2)
config = None
if (int(major) == 23 and int(patch) < 8) or (
int(major) == 24 and int(patch) < 1
):
config = {"ContainerSpec": {}}

container = docker.containers.container(container_id)
changes: list[str] = []
for label_name, label_value in extra_labels.items():
changes.append(f"LABEL {label_name}={label_value}")
if canonical:
if ":" in canonical:
repo, tag = canonical.rsplit(":", maxsplit=1)
Expand All @@ -210,6 +222,7 @@ def _write_chunks(
changes=changes,
repository=repo,
tag=tag,
config=config,
)
image_id = response["Id"]
if filename:
Expand Down

0 comments on commit f08911e

Please sign in to comment.