Check if docker is available and running.
(ctx: Context)
| 42 | |
| 43 | |
| 44 | def check_docker(ctx: Context) -> bool: |
| 45 | """ |
| 46 | Check if docker is available and running. |
| 47 | """ |
| 48 | docker = shutil.which("docker") |
| 49 | if not docker: |
| 50 | ctx.error("docker command not found in PATH") |
| 51 | return False |
| 52 | |
| 53 | # Check if docker daemon is running |
| 54 | ret = ctx.run("docker", "info", capture=True, check=False) |
| 55 | if ret.returncode != 0: |
| 56 | ctx.error("docker daemon is not running") |
| 57 | return False |
| 58 | |
| 59 | return True |
| 60 | |
| 61 | |
| 62 | @container_test.command( |
no test coverage detected