VS Code Tunnel server that allows you to access your development environment from anywhere using Visual Studio Code.
- 🚀 VS Code CLI with Remote Tunnels support
- 🐳 Docker-based setup for easy deployment
- 🔄 Auto-restart on failure
- 📁 Workspace volume mounted for persistent code
- 💾 Persistent VS Code settings and tunnel credentials across container restarts
# Clone the repository
git clone https://github.com/ngupuk/code-server.git
cd code-server
# Build and start the container
docker-compose up --build -d
# View logs to get the tunnel URL
docker-compose logs -fOnce the container is running, you'll see a tunnel URL in the logs. To connect from your local VS Code:
# Install VS Code CLI (if not already installed)# Then connect to your tunnel
code tunnel jekyllOr use the "Connect to Tunnel" feature in VS Code's Remote Explorer.
This container includes Docker CLI and docker-compose, allowing you to run Docker commands inside the development environment.
The container is configured with access to the host machine's Docker daemon via socket mounting (/var/run/docker.sock). This means:
- ✅ You can run
dockercommands inside the container - ✅ Containers built/run inside use the host's Docker daemon
- ✅ No Docker-in-Docker overhead or additional setup needed
IMPORTANT: Mounting the Docker socket grants the container user full access to the host's Docker daemon. This effectively grants them root-level access to the entire host system.
- Ensure you only use this container with trusted code
- Be cautious with projects from untrusted sources that run inside this container
- Consider this container as having root access to your machine
- Use with proper network isolation if needed
Once connected to your tunnel, you can run Docker commands:
# List running containers
docker ps
# Build an image
docker build -t my-image .# Run a container
docker run -it my-image bash
# Use docker-compose
docker-compose upThe non-root user is automatically added to the docker group, allowing Docker commands to be run without sudo.
If you encounter permission errors when running Docker commands:
- Ensure the Docker socket has the correct permissions on the host:
ls -l /var/run/docker.sock - The docker group GID inside the container should match the host's docker group GID
- You may need to restart the container after the host Docker daemon restarts
8080- Default port for VS Code tunnel connections
The docker-compose.yml includes three named volumes for data persistence:
vscode_data- Mounted to/home/vscode/.local/share/code-cli- Persists VS Code tunnel credentials and connection settings (prevents needing to reconnect after restart)vscode_config- Mounted to/home/vscode/.config/code-server- Persists VS Code extensions and user settingsvscode_home- Mounted to/home/vscode- Persists shell history and other user data./workspace- Mounted to/workspace- Contains your development files
When you restart a Docker container without volumes, all data inside the container is lost. This means:
- ❌ Without
vscode_datavolume: You'd need to reconnect to the tunnel again after each restart - ❌ Without
vscode_configvolume: Your VS Code extensions and settings would be lost - ✅ With these volumes: Everything persists across container restarts
List all volumes:
docker volume ls | grep vscodeRemove all VS Code volumes (be careful - this deletes saved data):
docker-compose down -vClean up unused volumes:
docker volume pruneYou can add these to docker-compose.yml:
environment:
- GITHUB_TOKEN=your_token # For GitHub Copilot integrationYou can also pull the pre-built image from GHCR:
docker pull ghcr.io/ngupuk/code-server:latest
docker run -d -p 8080:8080 ghcr.io/ngupuk/code-server:latestTo rebuild the image after making changes:
docker-compose build
docker-compose up -dCheck the logs:
docker-compose logs- Ensure port 8080 is accessible from your network
- Check firewall rules
- Verify the tunnel URL in the container logs
This indicates the volumes are not properly persisting data. To fix:
- First run: When you start the container for the first time, follow the tunnel setup instructions in the logs
- Restart: Subsequent restarts should NOT require reconnection because volumes persist the credentials
- If still reconnecting: Check that volumes are properly created:
docker volume ls | grep vscode
If you need to reset the tunnel connection:
# Stop the container
docker-compose down
# Remove specific volumes
docker volume rm $(docker volume ls -q | grep vscode_data)# Start fresh
docker-compose up -dThis project uses VS Code CLI. By using this tunnel, you agree to the VS Code license terms.
Note: This project was converted from code-server to VS Code Tunnel Server.