← Lab Notes
July 25, 2026 self-hosteddockervscodehomelab

Self-Hosted VS Code with Docker on a Homelab

Deploying code-server in a custom Docker container for remote coding from any browser—no laptop setup needed.


Overview

Self-hosted a full browser-based VS Code (code-server) at code.breadtoasting.com on 2026-07-10. This allows me to code from anywhere with just a browser, eliminating the need for laptop-specific setup.

Background

I frequently work across multiple devices and locations, making remote coding essential. The traditional approach of setting up VS Code on each device was cumbersome, so I decided to self-host it in a Docker container. This way, I can access my development environment from any machine with just a browser tab.

How It Works

Custom Docker Image

I built a custom Docker image based on the official code-server image and added the Docker CLI and Docker Compose plugin into it. The rationale behind this was to enable the integrated terminal inside the browser IDE to run docker/docker-compose commands directly against the same Docker host that everything else runs on.

Container Setup

The container runs as a non-root user matching my own host user ID, ensuring that files edited through it remain writable outside the container. This setup is crucial for seamless project management and file access.

File System Mounts

  • Home Directory: Mounted the entire home directory into the container to allow it to see and edit every project.
  • NAS Share: Also mounted a NAS share as a bind mount, providing additional storage options.
  • Config Volume: A fresh named volume was created for the container's own config directory. Initially, this required a one-time ownership fix because code-server couldn't write to it due to permission issues (e.g., mkdir: cannot create directory '/path/to/config': Permission denied).

Security Measures

Given the elevated permissions within the container, security is paramount. The setup involves two layers of protection:

  • code-server Password: A built-in password for code-server itself.
  • Cloudflare Access: An additional layer requiring a second-factor authentication before any request reaches the container.

Both measures are enabled to mitigate potential risks associated with direct access to the Docker host from within a browser tab.

Reverse Proxy Cache

One notable gotcha is that the reverse proxy in front of code-server caches the container's IP address. Therefore, after any recreation of the container, an explicit restart of the reverse proxy is required to ensure it routes requests correctly to the new IP address. Otherwise, requests will continue to fail due to routing to the old, now-dead IP.

Results

The setup works seamlessly for remote coding and provides a consistent development environment across multiple devices. The ability to run Docker commands directly from within the browser IDE is particularly powerful, enabling me to manage containerized applications effortlessly.

Lessons Learned

  • Security: Always implement multi-layer security measures when exposing sensitive services.
  • Reverse Proxy Management: Be mindful of caching mechanisms in reverse proxies and ensure they are properly managed during container recreation.
  • File System Access: Properly configure file system mounts and ownership settings to avoid permission issues.

By following these lessons, I can continue to enjoy the benefits of self-hosted VS Code while maintaining a high level of security.

Was this useful?