Skip to content

Commit

Permalink
Detect when inside an OCI container (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
blissd committed Jun 25, 2023
1 parent 2f13dea commit 30d23cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,13 @@ prompt_pure_state_setup() {
)
}

# Return true if executing inside a Docker, LXC or systemd-nspawn container.
# Return true if executing inside a Docker, OCI, LXC, or systemd-nspawn container.
prompt_pure_is_inside_container() {
local -r cgroup_file='/proc/1/cgroup'
local -r nspawn_file='/run/host/container-manager'
[[ -r "$cgroup_file" && "$(< $cgroup_file)" = *(lxc|docker)* ]] \
|| [[ "$container" == "lxc" ]] \
|| [[ "$container" == "oci" ]] \
|| [[ -r "$nspawn_file" ]]
}

Expand Down

0 comments on commit 30d23cb

Please sign in to comment.