docker.recipes

Code Server VS Code

beginner

VS Code in the browser with full extension support and persistent workspace.

Overview

Code-server is Microsoft's VS Code editor running entirely in a web browser, developed by Coder to enable remote development workflows. Originally created to solve the challenge of accessing powerful development environments from any device, code-server maintains full compatibility with VS Code extensions while running on remote servers or containers. This browser-based IDE has revolutionized how developers approach remote work and resource-intensive development tasks. This stack combines code-server with NGINX as a reverse proxy to create a robust web-based development environment. The NGINX component handles SSL termination, request routing, and can provide additional security layers through rate limiting and authentication. Code-server runs the actual VS Code instance with full extension marketplace access, integrated terminal, and file system operations, while NGINX manages external access and can serve static assets efficiently. Development teams working across multiple devices, organizations requiring consistent development environments, and individual developers seeking powerful remote coding capabilities will find this combination particularly valuable. The setup enables coding from tablets, Chromebooks, or any device with a modern browser while leveraging server-grade hardware for compilation, testing, and resource-intensive operations. Remote development teams can maintain identical environments regardless of local hardware constraints.

Key Features

  • Complete VS Code experience in browser with full extension marketplace access
  • Integrated terminal with sudo access for system-level operations
  • Real-time collaborative editing and shared development sessions
  • NGINX reverse proxy with SSL termination and custom domain support
  • Password and token-based authentication for secure access
  • Persistent workspace and configuration storage across container restarts
  • HTTP/2 support through NGINX for improved browser performance
  • Built-in file explorer with upload/download capabilities for local file management

Common Use Cases

  • 1Remote development teams maintaining consistent coding environments across different operating systems
  • 2Educational institutions providing standardized programming environments for students on various devices
  • 3Freelance developers working from client sites or co-working spaces without local development setup
  • 4Organizations developing on powerful cloud instances while using lightweight local devices
  • 5Development on ARM-based devices like Raspberry Pi with browser access from desktop machines
  • 6Secure coding environments where source code must remain on controlled servers
  • 7Multi-platform development requiring different toolchains available through containerized environments

Prerequisites

  • Minimum 2GB RAM recommended for smooth VS Code operation with multiple extensions
  • Docker host with ports 80, 443, and 8443 available for web access
  • Modern web browser with WebSocket support for real-time editor synchronization
  • Basic understanding of NGINX configuration for SSL certificates and custom domains
  • File system permissions allowing Docker volume mounting for persistent workspace storage

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 code-server:
3 image: lscr.io/linuxserver/code-server:latest
4 environment:
5 PUID: 1000
6 PGID: 1000
7 TZ: ${TZ}
8 PASSWORD: ${PASSWORD}
9 SUDO_PASSWORD: ${SUDO_PASSWORD}
10 ports:
11 - "8443:8443"
12 volumes:
13 - code_config:/config
14 - workspace:/workspace
15 networks:
16 - code-net
17 restart: unless-stopped
18
19 nginx:
20 image: nginx:alpine
21 ports:
22 - "80:80"
23 - "443:443"
24 volumes:
25 - ./nginx.conf:/etc/nginx/nginx.conf:ro
26 depends_on:
27 - code-server
28 networks:
29 - code-net
30 restart: unless-stopped
31
32volumes:
33 code_config:
34 workspace:
35
36networks:
37 code-net:
38 driver: bridge

.env Template

.env
1# Timezone
2TZ=UTC
3
4# Passwords
5PASSWORD=secure_password
6SUDO_PASSWORD=secure_sudo_password
7
8# User/Group IDs
9PUID=1000
10PGID=1000

Usage Notes

  1. 1VS Code at http://localhost:8443
  2. 2Enter password to access
  3. 3Full VS Code extension support
  4. 4Persistent workspace in /workspace

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

code-server
code-server:
  image: lscr.io/linuxserver/code-server:latest
  environment:
    PUID: 1000
    PGID: 1000
    TZ: ${TZ}
    PASSWORD: ${PASSWORD}
    SUDO_PASSWORD: ${SUDO_PASSWORD}
  ports:
    - "8443:8443"
  volumes:
    - code_config:/config
    - workspace:/workspace
  networks:
    - code-net
  restart: unless-stopped
nginx
nginx:
  image: nginx:alpine
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
  depends_on:
    - code-server
  networks:
    - code-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 code-server:
5 image: lscr.io/linuxserver/code-server:latest
6 environment:
7 PUID: 1000
8 PGID: 1000
9 TZ: ${TZ}
10 PASSWORD: ${PASSWORD}
11 SUDO_PASSWORD: ${SUDO_PASSWORD}
12 ports:
13 - "8443:8443"
14 volumes:
15 - code_config:/config
16 - workspace:/workspace
17 networks:
18 - code-net
19 restart: unless-stopped
20
21 nginx:
22 image: nginx:alpine
23 ports:
24 - "80:80"
25 - "443:443"
26 volumes:
27 - ./nginx.conf:/etc/nginx/nginx.conf:ro
28 depends_on:
29 - code-server
30 networks:
31 - code-net
32 restart: unless-stopped
33
34volumes:
35 code_config:
36 workspace:
37
38networks:
39 code-net:
40 driver: bridge
41EOF
42
43# 2. Create the .env file
44cat > .env << 'EOF'
45# Timezone
46TZ=UTC
47
48# Passwords
49PASSWORD=secure_password
50SUDO_PASSWORD=secure_sudo_password
51
52# User/Group IDs
53PUID=1000
54PGID=1000
55EOF
56
57# 3. Start the services
58docker compose up -d
59
60# 4. View logs
61docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/code-server-vscode/run | bash

Troubleshooting

  • Connection refused on port 8443: Verify code-server container is running and PASSWORD environment variable is set
  • Extensions fail to install: Increase container memory allocation and check internet connectivity for marketplace access
  • NGINX 502 Bad Gateway: Ensure code-server service is healthy and inter-container networking allows communication
  • Authentication loop or constant password prompts: Clear browser cookies and verify PASSWORD matches between attempts
  • File permissions denied in terminal: Check PUID/PGID environment variables match host user permissions
  • Slow performance or timeouts: Increase code-server container resources and verify NGINX upstream timeout settings

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space