MCPcopy Create free account
hub / github.com/Sagyam/linite / startContainer

Function startContainer

scripts/validate-seed-docker.ts:210–246  ·  view source on GitHub ↗
(config: ContainerConfig)

Source from the content-addressed store, hash-verified

208
209// Start a Docker container
210function startContainer(config: ContainerConfig): boolean {
211 // Pull image
212 console.log(` Pulling ${config.image}...`);
213 const pullResult = spawnSync('docker', ['pull', '-q', config.image], {
214 stdio: 'inherit',
215 timeout: 300000, // 5-minute timeout for pulls
216 });
217
218 if (pullResult.status !== 0) {
219 console.error(` ✗ Failed to pull image`);
220 return false;
221 }
222
223 // Remove the existing container if present
224 spawnSync('docker', ['rm', '-f', config.name], { stdio: 'ignore' });
225
226 // Start container (keep alive with sleep infinity)
227 const result = spawnSync('docker', [
228 'run', '-d', '--name', config.name,
229 '--dns', '1.1.1.1', '--dns', '1.0.0.1',
230 config.image, 'sleep', 'infinity'
231 ], { stdio: 'pipe' });
232
233 if (result.status !== 0) {
234 console.error(` ✗ Failed to start container`);
235 return false;
236 }
237
238 // Update package databases / setup (with a longer timeout for setup commands)
239 console.log(` Setting up environment...`);
240 if (!dockerExec(config.name, config.setupCommand, 120000)) {
241 console.error(` ✗ Failed to setup environment`);
242 return false;
243 }
244
245 return true;
246}
247
248// Stop and remove Docker container
249function stopContainer(name: string): void {

Callers 1

validateSourceFunction · 0.85

Calls 1

dockerExecFunction · 0.85

Tested by

no test coverage detected