Omniscio

OmniscioGuidesClaude Code in Docker on a Mac

Claude Code in Docker on a Mac

On a Mac the container is not running on your disk or your kernel: Docker Desktop runs a Linux virtual machine, and the container lives inside it. That is where the memory, the file speed and the sign-in problems come from.

Last checked against Anthropic's documentation on November 26, 2026. By the Omniscio team. Updated .

Is Docker on a Mac supported?

Yes, through the dev container route Anthropic documents. It publishes a dev container feature — ghcr.io/anthropics/devcontainer-features/claude-code:1.0 — that installs Claude Code into any container built to the Dev Containers spec, and it treats VS Code, GitHub Codespaces, JetBrains IDEs and Cursor as the editors that support that spec.

The container can run under Docker Desktop on a Mac, and Docker's own support covers both processor families: there are separate downloads for Apple silicon and for Intel chips. Docker says it supports the current and two previous major macOS releases, and asks for at least 4 GB of RAM.

Anthropic's documented model is the opposite of running the Mac's own claude and pointing it at files inside a container: Claude Code runs inside the container and edits the host repository through a bind mount, so it sees the same build tools and dependencies as the rest of the project.

How do I run Claude Code in a container on a Mac?

Install Docker Desktop for your processor, then create or edit .devcontainer/devcontainer.json in your repository. If the repository has no .devcontainer folder, make one and put the file in it:

{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
  }
}

Replace the image line with your project's base image, or remove it if your file already uses a Dockerfile, and keep the feature. The feature installs Node.js itself when the base image does not provide it.

Rebuild the container from the editor rather than the terminal — in VS Code that is Dev Containers: Rebuild Container, opened with Cmd + Shift + P on a Mac. Then open a terminal inside the container and run claude to sign in.

If the build stops with Failed to install Node.js and npm, add the Node feature above the Claude Code one and rebuild:

{
  "features": {
    "ghcr.io/devcontainers/features/node:1": {},
    "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
  }
}

Anthropic also publishes a reference container in its own repository, which combines the CLI, an egress firewall, persistent volumes and a Zsh shell. It calls that a working example rather than a maintained base image, so read it rather than depend on it.

One architecture note: the base image has to have a build for your machine. Apple silicon runs arm64 images natively; Docker recommends Rosetta 2 for the best experience and notes that a few amd64 command-line tools still require it.

Why am I signed out after every rebuild?

Because a container's home directory is discarded when it is rebuilt, and that is where Claude Code keeps its authentication token, user settings and session history — under ~/.claude. The account details, personal MCP servers and per-project trust live in a separate file, ~/.claude.json.

The fix is a named volume at that directory plus CLAUDE_CONFIG_DIR pointing at the same path, so Claude Code writes .claude.json inside that directory too. The path below is the placeholder for your container user's home — Anthropic's example is written for a container whose remoteUser is node. Add these two keys to devcontainer.json:

{
  "mounts": [
    "source=claude-code-config,target=/home/user/.claude,type=volume"
  ],
  "containerEnv": {
    "CLAUDE_CONFIG_DIR": "/home/user/.claude"
  }
}

Replace /home/user with the home directory of the user the container runs as. Run echo $HOME in the container's terminal to see the right path — the base image decides it, and not every image uses the same name. Anthropic names the exact failure this prevents: without CLAUDE_CONFIG_DIR, first-launch setup repeats after every rebuild, because the record that you completed it was in the discarded file.

If your devcontainer.json already has a containerEnv object, add CLAUDE_CONFIG_DIR to it rather than adding a second one, or the first object's variables are lost.

One warning worth repeating from that page: with --dangerously-skip-permissions, a dev container does not stop a malicious project from exfiltrating what is inside it, including the credentials in ~/.claude. Anthropic says to avoid mounting host secrets such as ~/.ssh into the container and to prefer repository-scoped or short-lived tokens.

Known issues on a Mac, and what fixes them

Sign-in opens no browser, or fails on localhost

Signing in inside a container cannot always reach the Mac's browser. Anthropic documents the way through: use the login URL the terminal prints above its paste prompt, open it in a browser on the Mac, sign in there, and paste back the code the browser shows.

Sandboxed commands fail with Operation not permitted

In an unprivileged container bubblewrap cannot mount a fresh /proc, so the sandbox fails with an error like Can't mount proc on /newroot/proc. Anthropic's fix is to let the sandbox reuse the container's existing /proc, by setting sandbox.enableWeakerNestedSandbox to true in your Claude Code settings file (~/.claude/settings.json, or the project's .claude/settings.json):

{
  "sandbox": {
    "enableWeakerNestedSandbox": true
  }
}

Anthropic says to use it only when the outer container already provides the isolation you need, since it exposes process information that a fresh /proc would hide.

The install hangs during a build

Anthropic gives two causes for an installer that hangs in Docker: no working directory set, and too little memory for the Docker Desktop virtual machine. Set WORKDIR /tmp before running the installer, and raise the memory limit in Docker Desktop's Settings > Resources.

Every file operation is slow on a big repository

On a Mac the container's files are not on your disk directly: they cross into Docker Desktop's virtual machine. Docker says its virtual filesystems, VirtioFS and gRPC FUSE, are "no longer scaling well" with large codebases, and offers synchronized file shares for repositories with 100,000 files or more — a Pro, Team or Business subscription feature rather than a free one.

Claude Code reads and searches the same bind-mounted tree your build does, so a large repository is the case where this bites.

The container runs out of memory

The memory the container can use is the memory Docker Desktop gave its virtual machine, and containers built there share it — Anthropic's own wording for build containers. Both vendors put their floor at 4 GB: Anthropic for the machine running Claude Code, Docker for the Mac running Docker Desktop. Set the virtual machine to at least 4 GB as a starting point in Settings > Resources, and more if the project builds heavily.

How do I confirm it works?

From a terminal inside the container, Anthropic's checks come first:

claude --version
claude doctor

A version number means the install completed, and claude doctor prints read-only installation and settings diagnostics without starting a session.

Then the container-specific checks:

  • Rebuild the container once and confirm you are still signed in. That is the volume and CLAUDE_CONFIG_DIR working.
  • Run /sandbox inside a Claude Code session. If anything is missing, a Dependencies tab names which of ripgrep, bubblewrap, socat and the seccomp filter your platform lacks; no tab means all present, and a panel with only that tab means the sandbox cannot start yet.
  • Check the memory the virtual machine was given with free -h — it reports the virtual machine's total, not any per-container cap — and compare it with Docker Desktop's Resources setting.

Where these answers come from

Common questions

Can you run Claude Code in Docker on a Mac?

Yes. Anthropic publishes a dev container feature and a reference container, and both run under Docker Desktop on Apple silicon or on an Intel Mac. Claude Code runs inside the container, not on the Mac host, so the container needs the tools your project builds with.

Which Docker Desktop build do I need on a Mac?

The one for your processor. Docker ships separate downloads for Apple silicon and for Intel chips, and Docker Desktop is supported on the current and two previous major macOS releases with at least 4 GB of RAM. On Apple silicon, Rosetta 2 is recommended but no longer strictly required; a few amd64 command-line tools still need it.

Why am I signed out every time the container rebuilds?

Because the container's home directory is discarded on rebuild, and Claude Code keeps its token, settings and session history in ~/.claude. Mount a named volume at ~/.claude and set CLAUDE_CONFIG_DIR to the same path, or the account details in ~/.claude.json are thrown away with the rest.

Why does the sandbox fail inside the container?

Bubblewrap cannot mount a fresh /proc in an unprivileged container, so sandboxed commands fail with an Operation not permitted error. Anthropic's documented fix is the enableWeakerNestedSandbox setting, which makes the sandbox reuse the container's own /proc.

Is Docker Desktop free to use with Claude Code?

Docker Desktop is free for personal use, education, non-commercial open source, and businesses under 250 employees and under 10 million dollars in annual revenue. Larger companies need a paid subscription for professional use, and government entities need one regardless of size.