-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathrun-podman-compose.ps1
More file actions
43 lines (35 loc) · 1.42 KB
/
run-podman-compose.ps1
File metadata and controls
43 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
param(
# Forward all remaining arguments to "podman compose"
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$ComposeArgs
)
$ErrorActionPreference = 'Stop'
# Enable verbose mode if VERBOSE=1
$verboseEnv = $env:VERBOSE
$VerboseEnabled = $false
if ($verboseEnv -eq '1') {
$VerboseEnabled = $true
$VerbosePreference = 'Continue'
Write-Verbose "Verbose mode enabled (VERBOSE=1)"
}
# Podman log level (debug if VERBOSE=1, otherwise info)
if (-not $env:PODMAN_LOG_LEVEL) {
if ($VerboseEnabled) {
$env:PODMAN_LOG_LEVEL = 'debug'
} else {
$env:PODMAN_LOG_LEVEL = 'info'
}
}
Write-Host ">> Using PODMAN_LOG_LEVEL=$($env:PODMAN_LOG_LEVEL)"
# 1) In the Podman VM, the Docker-compatible socket is /run/docker.sock
$env:DOCKER_SOCKET_PATH = "/run/docker.sock"
Write-Host ">> Using DOCKER_SOCKET_PATH=$($env:DOCKER_SOCKET_PATH)"
# (Optional) Make the socket readable/writable inside the Podman VM
$chmodCmd = "sudo chmod 666 /run/user/*/podman/podman.sock /run/docker.sock 2>/dev/null || true"
Write-Verbose "Running inside podman machine: $chmodCmd"
podman machine ssh -- "$chmodCmd" | Out-Null
# 2) Run podman compose with the right environment variables
$env:DOCKER_HOST = "unix:///var/run/docker.sock"
$cmdPreview = "podman --log-level=$($env:PODMAN_LOG_LEVEL) compose $($ComposeArgs -join ' ')"
Write-Host ">> Running: $cmdPreview"
podman --log-level=$env:PODMAN_LOG_LEVEL compose @ComposeArgs