Astro inside Container Machine

A Linux workspace for your Astro sites, running right on your Mac.

Released for Mac

Building the machine image from the Containerfile in Terminal
The Astro dev server running inside the machine
The site open in Safari, served from the machine

Astro inside Container Machine builds a small Linux machine with Apple's container tool and runs Node and Astro inside it. Your project stays in a normal folder on your Mac, and the dev server and builds run in Linux, the same way they do on GitHub Actions.

How it works

The machine starts from the official Node 24 image, with bash and git added. Clearing the image’s entrypoint lets the machine boot init like a full Linux system instead of dropping straight into Node:

FROM node:24-alpine
RUN apk add --no-cache bash git
# Clear the Node image's entrypoint so the machine boots init
ENTRYPOINT []
CMD ["/sbin/init"]

Build the image from the folder that holds the Containerfile, then create the machine from it. A new machine gets half your Mac’s memory by default, so cap it:

cd ~/Developer/Containers/Astro
container build -t local/astro-machine:latest .

container machine create local/astro-machine:latest --name astro
container machine set -n astro cpus=4 memory=4G
container machine stop astro
container machine run -n astro -- node -v   # should print v24.x

From then on, do all npm work inside the machine. Change to your project folder on the Mac, and each command runs there:

cd ~/Developer/Astro
container machine run -n astro -- npm install
container machine run -n astro -- npx astro dev --host 0.0.0.0
container machine run -n astro -- npm run build

The dev server is reachable from Safari at the machine’s IP address, and npm run build writes the finished site to dist/ in your Mac folder, ready to deploy. Run container machine set-default astro to drop the -n astro from every command.

What It Does