|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
use std::os::unix::fs::OpenOptionsExt;
|
|
|
|
use std::{io, fs, fmt, os, path, process, time};
|
|
|
|
use std::{io, fs, fmt, os, path, process, time};
|
|
|
|
use fmt::Display;
|
|
|
|
use fmt::Display;
|
|
|
|
use os::fd::{AsFd, AsRawFd};
|
|
|
|
use os::fd::{AsFd, AsRawFd};
|
|
|
@ -498,7 +499,8 @@ impl Display for ContainerInfo {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
let volume: String = self.volume.chars().take(20).collect();
|
|
|
|
let volume: String = self.volume.chars().take(20).collect();
|
|
|
|
let env: String = self.env.chars().take(20).collect();
|
|
|
|
let env: String = self.env.chars().take(20).collect();
|
|
|
|
write!(f, "\x1b[4m{:<10} {:<8} {:<10} {:<20} {:<20} {:<20} {:<10}\x1b[24m", self.id, self.pid, self.image, self.run, volume, env, &self.status)
|
|
|
|
let run: String = self.run.chars().take(20).collect();
|
|
|
|
|
|
|
|
write!(f, "\x1b[4m{:<10} {:<8} {:<10} {:<20} {:<20} {:<20} {:<10}\x1b[24m", self.id, self.pid, self.image, run, volume, env, &self.status)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -572,7 +574,6 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
|
|
|
|
for container_info in get_all_container_info()?{
|
|
|
|
for container_info in get_all_container_info()?{
|
|
|
|
stop_container(container_info.id.as_str(), is_remove)?
|
|
|
|
stop_container(container_info.id.as_str(), is_remove)?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
|
|
|
|
return Ok(())
|
|
|
|
return Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for container_id in containers_id.split(" ") {
|
|
|
|
for container_id in containers_id.split(" ") {
|
|
|
@ -671,10 +672,10 @@ fn main() -> Result<()>{
|
|
|
|
Ok(_) => {
|
|
|
|
Ok(_) => {
|
|
|
|
if container_info.wait {
|
|
|
|
if container_info.wait {
|
|
|
|
println!("🟢 容器 {} 运行完毕", container_info.id);
|
|
|
|
println!("🟢 容器 {} 运行完毕", container_info.id);
|
|
|
|
|
|
|
|
remove_network(&container_info.id);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
println!("🟢 主进程退出");
|
|
|
|
println!("🟢 主进程退出");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
remove_network(&container_info.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
Err(e) => {
|
|
|
|
// clone 之后的错误 这里已经无法捕获了
|
|
|
|
// clone 之后的错误 这里已经无法捕获了
|
|
|
|