# Run a Claude Code Dev Container on a Server Without VS Code

> Install Node 20+ and the Dev Containers CLI, then devcontainer up and exec run Claude Code over SSH. Watch for the UID 1000 clash.

Published: 2026-11-20. Author: Milan Jovanović.

Canonical: https://milanjovanovic.tech/blog/claude-code-devcontainer-cli

You can run a Claude Code dev container on a server with no screen or desktop, and you don't need VS Code.
Install Node 20 or later and the [**Dev Containers CLI**](https://github.com/devcontainers/cli), and put a `.devcontainer` folder in your repo.
Then `devcontainer up` builds and starts the container, and `devcontainer exec ... claude` starts Claude Code inside it.

I tested this on November 20, 2026, on a 2 vCPU / 8 GB Ubuntu 24.04 VPS with Docker 29.10, Dev Containers CLI 0.90.0, and Claude Code 2.1.329.
The container uses the .NET 11 SDK image and is based on Anthropic's [**reference dev container**](https://github.com/anthropics/claude-code/tree/main/.devcontainer).
I didn't try VS Code, Codespaces, or other base images.

One step failed quietly.
`devcontainer up` reported success, but the agent couldn't write a single file to the repo until I deleted one user from the image:

![Terminal output on the host. Without the userdel line, the container user claude has UID 1655, the ubuntu user holds UID 1000, and touch on /workspace/write-test fails with Permission denied. With userdel in the Dockerfile, claude has UID 1000 and the same touch exits with 0.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/uid_permission_denied.png)

## Can You Use Dev Containers Without VS Code?

Yes.
A **dev container** is a Docker container described by a `.devcontainer` folder in your repo.
The [**Claude Code dev container docs**](https://code.claude.com/docs/en/devcontainer) are written for editors, but the Dev Containers CLI reads the same `devcontainer.json` and drives Docker over plain SSH.

Your user needs to be in the `docker` group (`sudo usermod -aG docker $USER`, then log in again).
That group gives root-level access to the host, so keep that user for yourself.
My [**Ubuntu server hardening**](https://milanjovanovic.tech/blog/ubuntu-server-hardening) guide covers the user setup.

## Which Node.js Version Does the Dev Containers CLI Need?

Node 20 or later, according to the `engines` field in the CLI's `package.json` (`"node": ">=20.0.0"`).
Ubuntu 24.04's own `nodejs` package is older, so install Node from NodeSource, then the CLI:

```bash
curl -fsSL https://deb.nodesource.com/setup_26.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo apt-get install -y nodejs
sudo npm install -g @devcontainers/cli
```

![Terminal output on the host. Ubuntu](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/node_versions.png)

npm installed the CLI on Node 18 without complaint, but Node 18 is outside the range the CLI declares.
Node 22 from `setup_22.x` worked the same way as 26.

## How Do You Set Up a Claude Code Dev Container on a Server?

The setup is three files in `.devcontainer/`: `Dockerfile`, `devcontainer.json`, and the firewall script `init-firewall.sh`.
Download [**the complete dev container**](https://milanjovanovic.tech/code/claude-code-devcontainer.zip) and copy its `.devcontainer` folder into your repo.

![On the host, your SSH session runs the devcontainer CLI, which calls docker exec to reach the container, and the repo folder sits on the host disk. Inside the container, the claude user with UID 1000 sees the repo as a bind mount at /workspace, keeps its login in the claude-config volume, and sees the .devcontainer folder through a separate read-only mount.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/devcontainer_cli_on_vps.png)

These are the `devcontainer.json` lines that matter on a server:

```json
  "remoteUser": "claude",
  "mounts": [
    "source=claude-config-${devcontainerId},target=/home/claude/.claude,type=volume",
    "source=${localWorkspaceFolder}/.devcontainer,target=/workspace/.devcontainer,type=bind,readonly"
  ],
  "postStartCommand": "sudo /usr/local/bin/init-firewall.sh",
```

`remoteUser` is the user `devcontainer exec` runs as.
Claude Code refuses to skip permission prompts as root, so it has to be a normal user.

The first mount is a **named volume** (storage Docker keeps outside the container) at `~/.claude`.
It keeps the Claude Code login across rebuilds, as the [**dev container login guide**](https://milanjovanovic.tech/blog/claude-code-devcontainer-login) explains.

The second mount puts `.devcontainer` back over itself as read-only, so the agent can't edit its own container definition.
From inside the container, any change there failed with `Read-only file system`, including a new file and a delete.
The repo's `.git` folder has no such protection, and the [**git hooks escape guide**](https://milanjovanovic.tech/blog/devcontainer-git-hooks-escape) shows what that allows.

`postStartCommand` runs the firewall script at every start.
It runs as `claude`, so it needs `sudo`, and the [**firewall guide**](https://milanjovanovic.tech/blog/claude-code-devcontainer-firewall) covers what it allows.

## What Do the Up and Exec Commands Do?

`devcontainer up` builds the image and starts the container.
It also builds a second image with a `-uid` suffix, which changes the container user's **UID** (the numeric user ID Linux uses for file ownership) to match the owner of your repo.

```bash
cd ~/projects/orders-api
devcontainer up --workspace-folder .
```

The firewall output streams during `up`, and the success line comes last, because `"waitFor": "postStartCommand"` makes the CLI wait for the script:

![Terminal output of devcontainer up. After the container starts, the postStartCommand prints one Allowing line per host, such as api.anthropic.com and api.nuget.org, then Firewall configuration complete, Blocked https://example.com as expected, and Reached https://api.github.com as expected. The last line starts with outcome success.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/devcontainer_up_firewall.png)

Then start Claude Code:

```bash
devcontainer exec --workspace-folder . claude
```

On the host, `devcontainer exec` is a Node process that runs `docker exec` as `claude`, and it belongs to your SSH session.
When I killed the SSH client, the host side was gone within 10 seconds.
`claude` kept running in the container with no terminal to return to:

![Process lists while Claude Code runs. While connected, the host shows node running devcontainer exec and two docker exec processes as the claude user, and the container shows claude. Ten seconds after the SSH client was killed, the host list is empty and claude is still running in the container.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/exec_after_ssh_drop.png)

Start it inside tmux instead, as the [**Claude Code tmux guide**](https://milanjovanovic.tech/blog/claude-code-tmux) shows.

## Why Do You Get Permission Denied in a Dev Container?

The CLI gives the container user the UID of the repo owner, which is `1000` for the first user on a typical Ubuntu server.
In the .NET SDK image, a user named `ubuntu` already holds UID 1000:

```bash
docker run --rm mcr.microsoft.com/dotnet/sdk:11.0 getent passwd 1000
```

So `claude` got UID 1655 and couldn't write to the repo, as the first screenshot shows.
The `Dockerfile` in the download deletes that user before it creates `claude`:

```dockerfile
RUN userdel --remove ubuntu \
    && useradd --create-home --shell /bin/bash claude \
    && mkdir -p /workspace /home/claude/.claude \
    && chown -R claude:claude /workspace /home/claude/.claude
```

With it, `claude` got UID 1000, and the files it wrote belonged to my own user on the host.
Run the same `getent` check against any other base image before you use it.
If the UID changes after you've logged in, the login volume keeps the old owner, and the [**login guide**](https://milanjovanovic.tech/blog/claude-code-devcontainer-login) shows the fix.

## How Do You Open an App Running in the Dev Container?

Use an SSH tunnel to the container's IP address.
This `devcontainer.json` publishes no ports, so an app inside the container isn't reachable from the internet.

On November 22, Claude built a dashboard that listens on port 5080 in my container, and I opened it from my laptop:

```bash
# On the VPS: print the container's IP address (the name is in docker ps)
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>

# On your laptop: forward port 5080 to that address
ssh -N -L 5080:172.17.0.2:5080 agent@your-vps
```

The second command prints nothing while the tunnel is open.
`http://localhost:5080` then shows the app:

![A browser on localhost:5080 shows a server dashboard with CPU at 61%, 1.2 GB of memory used, a network chart, and a feed of the Bash commands Claude is running. Next to it, a phone shows the prompt that asked Claude to build it, in the claude-vps Remote Control session.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/phone_to_dashboard.png)

The tunnel works because the [**firewall**](https://milanjovanovic.tech/blog/claude-code-devcontainer-firewall) allows the Docker host network:

![A browser on a laptop at localhost:5080 goes through an SSH tunnel to sshd on the VPS, which reaches the dashboard in the dev container at 172.17.0.2 over the Docker bridge. Anyone else on the internet is stopped, because port 5080 is not published.](https://milanjovanovic.tech/blogs/articles/claude-code-devcontainer-cli/ssh_tunnel.png)

The app has to listen on `0.0.0.0`, because `127.0.0.1` inside the container isn't reachable from the host.

## How Do You Rebuild a Dev Container With the CLI?

Change the files on the host, since `.devcontainer` is read-only inside the container.
Then replace the container:

```bash
devcontainer up --workspace-folder . --remove-existing-container
```

Named volumes stay.
On my server, the same login volume survived several rebuilds.

## Summary

The Dev Containers CLI runs dev containers over plain SSH and needs Node 20 or later.
`devcontainer up` starts the container, and `devcontainer exec` runs Claude Code in it, preferably inside tmux.
If `/workspace` gives you `Permission denied`, check who holds UID 1000 in the base image first.

My [**self-hosting course**](https://milanjovanovic.tech/pragmatic-self-hosting) covers setting up the Ubuntu server that runs these containers.

Thanks for reading.

And stay awesome!

---

## Frequently asked questions

### Can you use dev containers without VS Code?

Yes. The Dev Containers CLI reads the same devcontainer.json file and runs it with Docker. devcontainer up builds and starts the container, and devcontainer exec runs a command inside it, such as claude. It works over plain SSH on a headless server.

### Which Node.js version does the Dev Containers CLI need?

Node 20 or later, according to the engines field in its package.json. Ubuntu 24.04 ships Node 18.19.1 in its own nodejs package, so install Node from NodeSource instead. A retest on Node 18.20.8 did not fail, but Node 18 is outside the range the CLI declares.

### Why do you get Permission denied in a dev container?

The container user has a different UID than the owner of your repo on the host. In the .NET SDK image, the ubuntu user already holds UID 1000, so the container user got UID 1655 and could not write to the mounted repo. Removing the ubuntu user in the Dockerfile gave it UID 1000 and fixed the writes.

### How do you rebuild a dev container with the CLI?

Run devcontainer up with the remove-existing-container option. It replaces the container with a new one built from your current files. Named volumes, such as the one that holds the Claude Code login, are not removed.
