How to Use Apple container Machines for VS Code Remote Development on Mac
Purpose
This post walks through setting up an Apple container machine with SSH and connecting from VS Code via Remote-SSH — giving you a Linux development environment with native IDE features on your Mac.
Why Container Machines for Development
The key advantage: your macOS home directory is mounted into the container machine automatically. Your repos, dotfiles, SSH keys — everything is available inside Linux without copying or syncing. Edit files in VS Code on macOS, compile and run inside Linux.

Prerequisites
- Apple container installed and running (
container system start) - VS Code with Remote-SSH extension
- A Dockerfile for the machine image
Step 1: Build the Machine Image
Create a Dockerfile with systemd and SSH:
FROM ubuntu:24.04RUN apt-get update && apt-get install -y systemd openssh-serverRUN systemctl enable sshCMD ["/sbin/init"]Build it:
container build -t ubuntu-machine:latest --file Dockerfile .Step 2: Create the Container Machine
container machine create --set-default --name ubuntu ubuntu-machine:latestStep 3: Set Up SSH
Start the machine and set a password for your macOS user:
container machine run -it sudo passwd $(whoami)Configure SSH on your Mac:
Host ubuntu.machine HostName ubuntu.machine User your-macos-username StrictHostKeyChecking no UserKnownHostsFile /dev/nullSet up DNS:
sudo container system dns create machineStep 4: Connect from VS Code
- Open VS Code
- Press
Cmd+Shift+P→ Remote-SSH: Connect to Host - Enter
ubuntu.machine - VS Code installs extensions on the remote machine
- Open your project from the mounted home directory
Development Workflow
Once connected, I can:
- Edit files in VS Code with macOS-native UI
- Build using Linux-native compilers inside the machine
- Debug with VS Code’s debugger attached to Linux processes
- Test with real services (PostgreSQL, Redis) running in the machine
# Build with Linux toolsgcc -o myapp myapp.c
# Run a servicesystemctl start postgresql
# Test your app./myappMulti-Distro Testing
Create separate machines for different distributions:
container machine create --name alpine-dev alpine:latestcontainer machine create --name ubuntu-dev ubuntu-machine:latestcontainer machine create --name debian-dev debian-machine:latestEach mounts the same home directory. Switch between them in VS Code by connecting to different hosts.
Cleanup
container machine stop ubuntucontainer machine delete ubuntucontainer image rm ubuntu-machine:latestRemove the SSH config entry and DNS domain manually.
Summary
In this post, I showed how to set up a container machine with SSH and use VS Code Remote-SSH for Linux development on Mac. The key point is that your macOS home directory is available inside the machine, so you edit on macOS and build/test inside Linux without any file syncing.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments