cli 0.1.12 specify whether to --add-host to core container

This commit is contained in:
mbecker20
2023-01-12 04:14:25 +00:00
parent 511efdc113
commit cfa3dd537d
4 changed files with 18 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -1472,7 +1472,7 @@ dependencies = [
[[package]]
name = "monitor_cli"
version = "0.1.11"
version = "0.1.12"
dependencies = [
"async_timing_util",
"clap",

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_cli"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["MoghTech"]
description = "monitor cli | tools to setup monitor system"

View File

@@ -220,6 +220,11 @@ pub fn start_core(sub_matches: &ArgMatches) {
.parse::<RestartMode>()
.expect("invalid restart mode");
let add_host = sub_matches
.get_one::<bool>("add-internal-host")
.map(|p| *p)
.unwrap_or(true);
println!(
"\n===================\n {} \n===================\n",
"core config".bold()
@@ -229,6 +234,7 @@ pub fn start_core(sub_matches: &ArgMatches) {
println!("{}: {port}", "port".dimmed());
println!("{}: {network}", "network".dimmed());
println!("{}: {restart}", "restart".dimmed());
println!("{}: {add_host}", "add internal host".dimmed());
if !skip_enter {
println!(
@@ -252,7 +258,13 @@ pub fn start_core(sub_matches: &ArgMatches) {
let _ = run_command_pipe_to_terminal(&format!("docker stop {name} && docker container rm {name}"));
let command = format!("docker run -d --name {name} -p {port}:9000 --network {network} -v {config_path}:/config/config.toml --restart {restart} --add-host host.docker.internal:host-gateway {CORE_IMAGE_NAME}");
let add_host = if add_host {
" --add-host host.docker.internal:host-gateway"
} else {
""
};
let command = format!("docker run -d --name {name} -p {port}:9000 --network {network} -v {config_path}:/config/config.toml --restart {restart}{add_host} {CORE_IMAGE_NAME}");
let output = run_command_pipe_to_terminal(&command);

View File

@@ -110,6 +110,9 @@ fn cli() -> Command {
.arg(
arg!(--restart <RESTART> "sets docker restart mode of monitor core container. default is unless-stopped")
)
.arg(
arg!(--add-internal-host "adds the docker flag '--add-host=host.docker.internal:host-gateway'. default is true")
)
),
)
.subcommand(