Skip to content

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.

Diagram showing macOS host with VS Code connected via Remote-SSH to an Apple container machine running Linux, with the macOS home directory mounted inside the container

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:

Dockerfile
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y systemd openssh-server
RUN systemctl enable ssh
CMD ["/sbin/init"]

Build it:

Build the machine image
container build -t ubuntu-machine:latest --file Dockerfile .

Step 2: Create the Container Machine

Create the container machine
container machine create --set-default --name ubuntu ubuntu-machine:latest

Step 3: Set Up SSH

Start the machine and set a password for your macOS user:

Start machine and set password
container machine run -it sudo passwd $(whoami)

Configure SSH on your Mac:

~/.ssh/config
Host ubuntu.machine
HostName ubuntu.machine
User your-macos-username
StrictHostKeyChecking no
UserKnownHostsFile /dev/null

Set up DNS:

Create DNS domain for the machine
sudo container system dns create machine

Step 4: Connect from VS Code

  1. Open VS Code
  2. Press Cmd+Shift+P → Remote-SSH: Connect to Host
  3. Enter ubuntu.machine
  4. VS Code installs extensions on the remote machine
  5. 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
Inside the remote VS Code terminal
# Build with Linux tools
gcc -o myapp myapp.c
# Run a service
systemctl start postgresql
# Test your app
./myapp

Multi-Distro Testing

Create separate machines for different distributions:

Multiple machines for different distros
container machine create --name alpine-dev alpine:latest
container machine create --name ubuntu-dev ubuntu-machine:latest
container machine create --name debian-dev debian-machine:latest

Each mounts the same home directory. Switch between them in VS Code by connecting to different hosts.

Cleanup

Remove the container machine
container machine stop ubuntu
container machine delete ubuntu
container image rm ubuntu-machine:latest

Remove 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