Run a command in the image. Creates a container from the image and runs the command described by `args` in the image.
(
self,
args: list[str] = [],
docker_args: list[str] = [],
env: dict[str, str] = {},
)
| 1215 | return (is_docker_image_public(spec), is_ghcr_image_public(ghcr_spec)) |
| 1216 | |
| 1217 | def run( |
| 1218 | self, |
| 1219 | args: list[str] = [], |
| 1220 | docker_args: list[str] = [], |
| 1221 | env: dict[str, str] = {}, |
| 1222 | ) -> None: |
| 1223 | """Run a command in the image. |
| 1224 | |
| 1225 | Creates a container from the image and runs the command described by |
| 1226 | `args` in the image. |
| 1227 | """ |
| 1228 | envs = [] |
| 1229 | for key, val in env.items(): |
| 1230 | envs.extend(["--env", f"{key}={val}"]) |
| 1231 | spawn.runv( |
| 1232 | [ |
| 1233 | "docker", |
| 1234 | "run", |
| 1235 | "--tty", |
| 1236 | "--rm", |
| 1237 | *envs, |
| 1238 | "--init", |
| 1239 | *docker_args, |
| 1240 | self.spec(), |
| 1241 | *args, |
| 1242 | ], |
| 1243 | ) |
| 1244 | |
| 1245 | def list_dependencies(self, transitive: bool = False) -> set[str]: |
| 1246 | out = set() |