Live data from Hacker News

Switching to Claude Code and VSCode Inside Docker

timsh.org

31–40 of 170 posts

Re: Switching to Claude Code and VSCode Inside Docker

#31

2-ish questions: Is this level of fear typical or reasonable? If so, why doesn’t Anthropic / AI code gen providers offer this type of service? Hard to believe Anthropic is not secure in some sense — like what if Claude Code is already inside some container-like thing? Is it actually true that Claude cannot bust out of the container?

> Is this level of fear typical or reasonable?

Just a month ago, an AI coding agent deleted all the files on someone's computer and there was a little discussion of it here on HN. Support's response was basically "yeah, this happens sometimes".

forum post: https://forum.cursor.com/t/cursor-yolo-deleted-everything-in...

HN thread (flagged, probably because it was a link to some crappy website that restates things from social media with no substantive content of its own): https://news.ycombinator.com/item?id=44262383

Idk how Claude Code works in particular, though.

Re: Switching to Claude Code and VSCode Inside Docker

#32
post #26

I use DevPod [1] to run Claude Code within Docker-based dev container environments, and it's been fairly seamless. It lets me run environments locally and focus Claude's context on just the repo I want it to work on. [1]: https://devpod.sh/

Interesting. Works with claude max or API only?

Re: Switching to Claude Code and VSCode Inside Docker

#33
If you are using Claude Code on macOS running it in a devcontainer has a few upsides like fewer cli tool call failures, meaning less waiting time and less context window spam.

But there are some things you lose as well @ ergonomics:

- "done" notifications are not working by default (might be possible trigger and send to host using hooks feature)

- more difficult to give playwright a session (need to get cookies into playwright in the container)

- can't easily paste screenshots into the devcontainer (Claude Code has to take a screenshot or you have to put it into a mounted dir)

and of course the usual advantages of using containers still apply (dependency management, reproducibility and so on).

I still wonder though if nix would allow me to remove the container overhead (they do noticeably tax the macbook battery).

Re: Switching to Claude Code and VSCode Inside Docker

#34

I have enjoyed running Claude Code in a container. The biggest advantage for me isn't security though, it's how easy it becomes to spin off agents to work in the background. I use a simple script that copies my working directory into a container, prompts Claude Code, and then either saves a planning document locally, or opens a pull request in GitHub for me to review. I quite like this because it makes starting agent…

Even locally, Claude in multiple terminal tabs/windows can do different tasks in parallel

They can, but I find it harder to review if you are trying to get Claude Code to do anything non-trivial. I've seen some people make multiple git worktrees so they can have two instances of Claude Code working independently, but I found that to be tedious to manage.

Re: Switching to Claude Code and VSCode Inside Docker

#35

If you are a VSCode hater (like me), you can achieve the same thing using the open-source, Microsoft-built, official devcontainer CLI [0], which is exactly what VSCode uses under the hood. You don't get automatic port forwarding with this tool, which includes SSH Agent forwarding, so you'll likely want to pair this with installing SSH into your devcontainers, or using some other tool that does the job. I built a tool…

devpod is quite nice for this

https://devpod.sh/

Re: Switching to Claude Code and VSCode Inside Docker

#36
post #23

I have enjoyed running Claude Code in a container. The biggest advantage for me isn't security though, it's how easy it becomes to spin off agents to work in the background. I use a simple script that copies my working directory into a container, prompts Claude Code, and then either saves a planning document locally, or opens a pull request in GitHub for me to review. I quite like this because it makes starting agent…

Any interest in sharing the script?

I'm afraid it is not that shareable as it contains a lot of dependency management and setup that is specific to my setup and projects. But it's not too complicated. You could probably re-create your own version fairly quickly.

It's just a Dockerfile that installs dependencies, an entrypoint that invokes claude, and some wrapper scripts that handle creating the container, passing through the prompt, and managing the results (e.g., output markdown to a directory, or open a PR). For input/output from the container I mount directories within the Docker container to local directories under ~/.call_claude/. I create a directory under there, clone the source code to it, output the prompt to a text file, and then grab results from that directory after Claude Code has finished running.

Re: Switching to Claude Code and VSCode Inside Docker

#38

I have enjoyed running Claude Code in a container. The biggest advantage for me isn't security though, it's how easy it becomes to spin off agents to work in the background. I use a simple script that copies my working directory into a container, prompts Claude Code, and then either saves a planning document locally, or opens a pull request in GitHub for me to review. I quite like this because it makes starting agent…

Have you tried setting up multiple git worktrees as well? I wonder if that doesn’t solve most of the issues.

Re: Switching to Claude Code and VSCode Inside Docker

#39

And you don't need to stop there. Claude Code also has great open alternatives you can run in any environment you like, with any model, and under economic arrangements you define. See https://oss-ai-swe.org/ for a few. My current favs are OpenHands and Codex CLI.

Aren’t those _way_ more expensive per token?

Re: Switching to Claude Code and VSCode Inside Docker

#40
post #38

I have enjoyed running Claude Code in a container. The biggest advantage for me isn't security though, it's how easy it becomes to spin off agents to work in the background. I use a simple script that copies my working directory into a container, prompts Claude Code, and then either saves a planning document locally, or opens a pull request in GitHub for me to review. I quite like this because it makes starting agent…

Have you tried setting up multiple git worktrees as well? I wonder if that doesn’t solve most of the issues.

It does, yes, and it's what Claude Code recommends officially.
Post reply on HN