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

Adds numerous bug fixes for remote cross. #922

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
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
21 changes: 15 additions & 6 deletions src/bin/commands/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub fn create_persistent_volume(
let state = docker::remote::container_state(engine, &container, msg_info)?;
if !state.is_stopped() {
msg_info.warn("container {container} was running.")?;
docker::remote::container_stop(engine, &container, msg_info)?;
docker::remote::container_stop_default(engine, &container, msg_info)?;
}
if state.exists() {
msg_info.warn("container {container} was exited.")?;
Expand All @@ -407,14 +407,24 @@ pub fn create_persistent_volume(
let mount_prefix = docker::remote::MOUNT_PREFIX;
let mut docker = docker::subcommand(engine, "run");
docker.args(&["--name", &container]);
docker.arg("--rm");
docker.args(&["-v", &format!("{}:{}", volume, mount_prefix)]);
docker.arg("-d");
if io::Stdin::is_atty() && io::Stdout::is_atty() && io::Stderr::is_atty() {
let is_tty = io::Stdin::is_atty() && io::Stdout::is_atty() && io::Stderr::is_atty();
if is_tty {
docker.arg("-t");
}
docker.arg(docker::UBUNTU_BASE);
// ensure the process never exits until we stop it
docker.args(&["sh", "-c", "sleep infinity"]);
if !is_tty {
// ensure the process never exits until we stop it
// we only need this infinite loop if we don't allocate
// a TTY. this has a few issues though: now, the
// container no longer responds to signals, so the
// container will need to be sig-killed.
docker.args(&["sh", "-c", "sleep infinity"]);
}
// store first, since failing to non-existing container is fine
docker::remote::create_container_deleter(engine.clone(), container.clone());
docker.run_and_get_status(msg_info, false)?;

docker::remote::copy_volume_container_xargo(
Expand Down Expand Up @@ -443,8 +453,7 @@ pub fn create_persistent_volume(
msg_info,
)?;

docker::remote::container_stop(engine, &container, msg_info)?;
docker::remote::container_rm(engine, &container, msg_info)?;
docker::remote::drop_container(is_tty, msg_info);

Ok(())
}
Expand Down
Loading