Menu

Run Docker containers inside Vercel Sandbox - Vercel
📰

Run Docker containers inside Vercel Sandbox - Vercel

Vercel News·Brandon Tuttle·6 months ago
#DAYa7XSt
#vercel#sandbox#docker#await#runcommand
Reading 0:00
15s threshold

Vercel Sandbox now supports installing and running Docker inside a sandbox. An agent can build containers, install system packages, and modify files without touching your host system.

Install Docker, start the daemon, and serve a containerized application:

import { Sandbox } from "@vercel/sandbox" ;

const sandbox = await Sandbox . create ( ) ;

await sandbox . runCommand ( {

sudo : true ,

cmd : "dnf" ,

args : [ "install" , "-y" , "docker" ]

} ) ;

// Start docker daemon and wait for it to be ready

await sandbox . runCommand ( { sudo : true , cmd : "dockerd" , detached : true } ) ;

await sandbox . runCommand ( {

cmd : "sh" ,

args : [ "-lc" , "until sudo docker info >/dev/null 2>&1; do sleep 1; done" ]

} ) ;

await sandbox . runCommand ( {

cmd : "docker" ,

args : [

"run" , "--rm" , "-d" ,

"--name" , "redis" ,

"redis:alpine"

]

} ) ;

await sandbox .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.