Write bytes to a path inside a container. Uses ``docker exec`` (not ``docker cp``) so the write happens from the container's own view of the filesystem — under gVisor, ``/tmp`` is an in-sandbox tmpfs that host-side ``docker cp`` can't reach.
(container: str, path: str, content: bytes)
| 95 | |
| 96 | |
| 97 | def write_file(container: str, path: str, content: bytes) -> None: |
| 98 | """Write bytes to a path inside a container. |
| 99 | |
| 100 | Uses ``docker exec`` (not ``docker cp``) so the write happens from the |
| 101 | container's own view of the filesystem — under gVisor, ``/tmp`` is an |
| 102 | in-sandbox tmpfs that host-side ``docker cp`` can't reach.""" |
| 103 | subprocess.run( |
| 104 | ["docker", "exec", "-i", container, "sh", "-c", 'cat > "$1"', "_", path], |
| 105 | input=content, |
| 106 | check=True, |
| 107 | capture_output=True, |
| 108 | ) |
| 109 | |
| 110 | |
| 111 | def rm(container: str) -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected