Skip to content

Commit

Permalink
Enable docker detect for WSL2 (#307)
Browse files Browse the repository at this point in the history
Enabled docker detect for Ubuntu in WSL2 distributions.
  • Loading branch information
hansieodendaal committed Feb 6, 2024
1 parent 56b74bf commit e97b338
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions cli/src/component/widgets/docker_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ use crate::component::{widgets::popup::Popup, Frame};

pub fn is_docker_running() -> bool {
match std::process::Command::new("docker").arg("version").output() {
Ok(output) => output.stderr.is_empty(),
Ok(output) => {
let is_wsl2_error =
String::from_utf8_lossy(&output.stdout).contains("The command 'docker' could not be found");
output.stderr.is_empty() && !is_wsl2_error
},
Err(_) => false,
}
}
Expand All @@ -36,8 +40,8 @@ pub fn display_docker_notice<B: Backend>(f: &mut Frame<B>, title: &str, msg: &st
let popup_area = Rect {
x: 4,
y: 2,
width: 50,
height: 8,
width: 80,
height: 10,
};
let popup = Popup::default()
.content(msg)
Expand Down
6 changes: 3 additions & 3 deletions cli/src/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ impl Actor for Dashboard {
let url = "https://docs.docker.com/engine/install/ubuntu/";

let msg = format!(
"\nThe Docker process is not detected.\nIs it installed and running?\n\
Download docker at {url}\n\
'Ctrl Q' to quit."
"\nThe Docker process is not detected.\nIs it installed and running?\n\n\
Download docker at {url}\n\n\
Press any key to quit."
);
if self
.terminal
Expand Down

0 comments on commit e97b338

Please sign in to comment.