Public Access
DEVX-155: fix: use /dev/shm/docker.sock socket for local dockerd
The existing dockerd holds /var/run/docker.sock and can't be killed from inside the container (different PID namespace). Use a new socket path /dev/shm/docker.sock and data root /dev/shm/docker (16G tmpfs). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
c61e4b3cab
commit
5e1337e524
@@ -23,6 +23,7 @@ Usage::
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
@@ -223,24 +224,23 @@ def start_docker_daemon(timeout: int = DEFAULT_TIMEOUT) -> bool:
|
||||
|
||||
click.echo(_("Host Docker not available, starting local dockerd..."))
|
||||
|
||||
# Kill any existing dockerd that's using the default data root on the
|
||||
# CI container's overlay (38G, often 100% full). The new dockerd will
|
||||
# use /dev/shm/docker (16G tmpfs) which has plenty of space.
|
||||
subprocess.run( # nosec B603 B607
|
||||
["pkill", "-f", "dockerd"],
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
time.sleep(2)
|
||||
# The existing dockerd (started by the CI image) uses the default data
|
||||
# root on the CI container's overlay (38G, often 100% full). We can't
|
||||
# kill it (different PID namespace) or bind to the same socket. Use a
|
||||
# new socket path and data root on /dev/shm (16G tmpfs).
|
||||
local_sock = "/dev/shm/docker.sock" # nosec B108
|
||||
docker_data_root = "/dev/shm/docker" # nosec B108
|
||||
|
||||
# Reset DOCKER_HOST to host socket for local dockerd
|
||||
os.environ["DOCKER_HOST"] = f"unix://{DOCKER_SOCK}"
|
||||
# Remove stale socket if present
|
||||
with contextlib.suppress(OSError):
|
||||
os.unlink(local_sock)
|
||||
|
||||
os.environ["DOCKER_HOST"] = f"unix://{local_sock}"
|
||||
|
||||
# Start local dockerd (requires privileged container)
|
||||
# Use /dev/shm/docker as data root — the CI container's overlay (38G)
|
||||
# is often 100% full, causing image pull failures. /dev/shm is a 16G
|
||||
# tmpfs with plenty of space for molecule test images.
|
||||
docker_data_root = "/dev/shm/docker" # nosec B108
|
||||
log_file = tempfile.NamedTemporaryFile( # noqa: SIM115
|
||||
mode="w", suffix="dockerd.log", delete=False
|
||||
)
|
||||
@@ -253,7 +253,7 @@ def start_docker_daemon(timeout: int = DEFAULT_TIMEOUT) -> bool:
|
||||
"--data-root",
|
||||
docker_data_root,
|
||||
"-H",
|
||||
f"unix://{DOCKER_SOCK}",
|
||||
f"unix://{local_sock}",
|
||||
],
|
||||
stdout=log_file,
|
||||
stderr=subprocess.STDOUT,
|
||||
|
||||
Reference in New Issue
Block a user