Running VS Code inside Docker
coder shifts software development from local machines to the cloud.
You can run VS Code on a server side docker container and access it using HTTPS. All that is required on the client is a modern web browser on any device - laptop, iPad, etc. This setup works for a single developer only and is not multi-user or multi-tenant ready.
The LinuxServer.io provides code-server docker images for 64bit Intel and ARM architectures.
See also: remote-development for other remote development approaches.
Installing
# Ensure config/ folder is writable by the user who is going to run code-server
mkdir config
chown 1002:1002 configFile: docker-compose.yaml
# Filename: docker-compose.yaml
# Run VS Code (code-serve) inside docker and publish it via traefik.io.
#
# Note: this is NOT a multi-user setup as the UID/GID is for a specific user.
version: "2.4"
services:
code:
image: lscr.io/linuxserver/code-server:latest
container_name: code.rsubr.in
restart: unless-stopped
environment:
- PUID=1002
- PGID=1002
- TZ=Asia/Kolkata
- PASSWORD=secretpassword
# - HASHED_PASSWORD=
- SUDO_PASSWORD=secretpassword
# - SUDO_PASSWORD_HASH= #optional
- PROXY_DOMAIN=code.rsubr.in
- DEFAULT_WORKSPACE=/config/workspace #optional
volumes:
- ./config:/config
# Mount your project folders from the host
- /home/rsubr/projects:/home/rsubr/projects
- /opt/go:/opt/go:ro
# Mount host binaries as required, docker is needed to start/stop host containers
- /usr/local/bin:/usr/local/bin:ro
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker:ro
labels:
- com.centurylinklabs.watchtower.enable=true
- traefik.enable=true
- traefik.http.routers.code.rule=Host(`code.rsubr.in`)
- traefik.http.routers.code.tls=true
- traefik.http.routers.code.tls.certresolver=lets-encryptReferences:
- LinuxServer docker code-server: https://docs.linuxserver.io/images/docker-code-server/