MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / run_container_inner

Method run_container_inner

src/docker/mod.rs:707–829  ·  view source on GitHub ↗

Execute the container lifecycle without performing resource cleanup. Returns the container ID (if one was created) and the DIND storage strategy alongside the execution result, so the caller can clean up everything in one place.

(
        &self,
        docker_image_tag: &str,
        task: &crate::task::Task,
        agent: &dyn Agent,
        network_name: Option<&str>,
        proxy_config: Option<&crate::context::Resolved

Source from the content-addressed store, hash-verified

705 /// alongside the execution result, so the caller can clean up everything in
706 /// one place.
707 async fn run_container_inner(
708 &self,
709 docker_image_tag: &str,
710 task: &crate::task::Task,
711 agent: &dyn Agent,
712 network_name: Option<&str>,
713 proxy_config: Option<&crate::context::ResolvedProxyConfig>,
714 proxy_container_ip: Option<&str>,
715 ) -> (
716 Option<String>,
717 DindStorage,
718 Result<(String, crate::agent::TaskResult), String>,
719 ) {
720 let suppress_stdout = self.event_sender.is_some();
721 let (config, dind_storage) = self.create_container_config(
722 docker_image_tag,
723 task,
724 agent,
725 network_name,
726 proxy_config,
727 proxy_container_ip,
728 );
729 let container_name = self.build_container_name(task);
730 let options = bollard::query_parameters::CreateContainerOptionsBuilder::default()
731 .name(&container_name)
732 .build();
733
734 let container_id = match self.client.create_container(Some(options), config).await {
735 Ok(id) => id,
736 Err(e) => return (None, dind_storage, Err(e)),
737 };
738
739 // Copy agent files into container before starting
740 for (tar_data, dest_path) in agent.files_to_copy() {
741 if let Err(e) = self
742 .client
743 .upload_to_container(&container_id, &dest_path, tar_data)
744 .await
745 {
746 return (Some(container_id), dind_storage, Err(e));
747 }
748 }
749
750 if let Err(e) = self.client.start_container(&container_id).await {
751 return (Some(container_id), dind_storage, Err(e));
752 }
753
754 let result = if task.is_interactive {
755 println!("\nStarting interactive session...");
756
757 match self.client.attach_container(&container_id).await {
758 Ok(()) => {
759 println!("\nInteractive session ended");
760 Ok((
761 String::new(),
762 crate::agent::TaskResult {
763 success: true,
764 message: "Interactive session completed".to_string(),

Callers 1

run_task_containerMethod · 0.80

Calls 15

build_container_nameMethod · 0.80
open_agent_logMethod · 0.80
tsk_envMethod · 0.80
stream_container_logsMethod · 0.80
buildMethod · 0.45
nameMethod · 0.45
create_containerMethod · 0.45
files_to_copyMethod · 0.45
upload_to_containerMethod · 0.45
start_containerMethod · 0.45
attach_containerMethod · 0.45

Tested by

no test coverage detected