Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated how we check if Docker is running to work with the new cgroup v2 system. #1259

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main/java/io/github/bonigarcia/wdm/docker/DockerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ public String getHost(String containerId, String network) {
return host;
}

public boolean isRunningInsideDocker() {
String[] commandArray = new String[] { "bash", "-c",
"cat /proc/self/cgroup | grep docker" };
private boolean isCommandResultPresent(String command) {
String[] commandArray = new String[] { "bash", "-c", command };
String commandOutput = runAndWait(false, commandArray);
return !isNullOrEmpty(commandOutput);
}

public boolean isRunningInsideDocker(){
return isCommandResultPresent("cat /proc/self/cgroup | grep docker") ||
isCommandResultPresent("cat /proc/self/mountinfo | grep docker/containers");
}

public String getDefaultHost() {
return Optional.ofNullable(dockerHostUri.getHost())
.orElse(defaultAddress());
Expand Down
Loading