|
|
@ -227,7 +227,7 @@ fn run_container(cmd: &String, wait:bool, log:bool, volume_path: &PathBuf) -> Re
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化容器工作目录
|
|
|
|
// 初始化容器工作目录
|
|
|
|
let _container_id = uuid::Uuid::new_v4().to_string();
|
|
|
|
let _container_id = uuid::Uuid::new_v4().to_string()[0..8].to_string();
|
|
|
|
let container_work_path = Path::new(WORKSPACE).join("containers").join(&_container_id);
|
|
|
|
let container_work_path = Path::new(WORKSPACE).join("containers").join(&_container_id);
|
|
|
|
let container_upper_path = container_work_path.join("upper");
|
|
|
|
let container_upper_path = container_work_path.join("upper");
|
|
|
|
let container_merged_path = container_work_path.join("merged");
|
|
|
|
let container_merged_path = container_work_path.join("merged");
|
|
|
@ -290,8 +290,8 @@ struct ContainerInfo {
|
|
|
|
id: String,
|
|
|
|
id: String,
|
|
|
|
run: String,
|
|
|
|
run: String,
|
|
|
|
image: String,
|
|
|
|
image: String,
|
|
|
|
volume: Option<String>,
|
|
|
|
volume: String,
|
|
|
|
env: Option<String>,
|
|
|
|
env: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn save_container_info(args: &RockerArgs, container_id: &String) -> Result<()> {
|
|
|
|
fn save_container_info(args: &RockerArgs, container_id: &String) -> Result<()> {
|
|
|
@ -300,8 +300,8 @@ fn save_container_info(args: &RockerArgs, container_id: &String) -> Result<()> {
|
|
|
|
id: container_id.clone(),
|
|
|
|
id: container_id.clone(),
|
|
|
|
run: args.run.as_ref().unwrap().clone(),
|
|
|
|
run: args.run.as_ref().unwrap().clone(),
|
|
|
|
image: args.image.as_ref().unwrap().clone(),
|
|
|
|
image: args.image.as_ref().unwrap().clone(),
|
|
|
|
volume: None,
|
|
|
|
volume: "".to_string(),
|
|
|
|
env: None
|
|
|
|
env: "".to_string()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let toml_str = toml::to_string(&container_info)?;
|
|
|
|
let toml_str = toml::to_string(&container_info)?;
|
|
|
|
fs::write(container_info_path, toml_str)?;
|
|
|
|
fs::write(container_info_path, toml_str)?;
|
|
|
@ -312,13 +312,13 @@ fn save_container_info(args: &RockerArgs, container_id: &String) -> Result<()> {
|
|
|
|
fn show_containers() -> Result<()> {
|
|
|
|
fn show_containers() -> Result<()> {
|
|
|
|
let containers_path = Path::new(WORKSPACE).join("containers");
|
|
|
|
let containers_path = Path::new(WORKSPACE).join("containers");
|
|
|
|
|
|
|
|
|
|
|
|
println!("{}{}{}{}{}", "id", "image", "run", "volume", "env");
|
|
|
|
println!("{:<20}{:<20}{:<20}{:<20}{:<20}", "id", "image", "run", "volume", "env");
|
|
|
|
for entry in fs::read_dir(containers_path)? {
|
|
|
|
for entry in fs::read_dir(containers_path)? {
|
|
|
|
let path = entry?.path();
|
|
|
|
let path = entry?.path();
|
|
|
|
let info_path = path.join("info.toml");
|
|
|
|
let info_path = path.join("info.toml");
|
|
|
|
let info_str = fs::read_to_string(info_path)?;
|
|
|
|
let info_str = fs::read_to_string(info_path)?;
|
|
|
|
let container_info: ContainerInfo = toml::from_str(&info_str)?;
|
|
|
|
let container_info: ContainerInfo = toml::from_str(&info_str)?;
|
|
|
|
println!("{}{}{}{:?}{:?}", container_info.id, container_info.image, container_info.run, container_info.volume, container_info.env);
|
|
|
|
println!("{:<20}{:<20}{:<20}{:<20}{:<20}", container_info.id, container_info.image, container_info.run, &container_info.volume[0..20], &container_info.env[0..20]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|