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

fix: container commit not working on Docker 23 #2040

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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