The project aims to provide a simple solution to run code-server in docker with a self-signed SSL certificate and persistent data support.
- Clone the repository
git clone https://github.com/sund3RRR/docker-code-server.git- Run the docker compose
docker compose up -d- Clone the repository
git clone https://github.com/sund3RRR/docker-code-server.git- Generate a self-signed certificate
./scripts/gen-cert- Run the docker compose
docker-compose up -d -f docker-compose-https.yaml- Clone the repository
git clone https://github.com/sund3RRR/docker-code-server.git- Generate a self-signed certificate
./scripts/gen-cert- Copy the
nginxfolder for nginx container
mkdir -p /DATA/AppData/code-server
cp -r nginx/ /DATA/AppData/code-server/- Select
code-server-https.yamlfrom casaos/ folder to add new app
- HTTPS with a self-signed certificate
- A non-root user in the code-server container
- Persistent data for the container's home directory
- Pre-installed
nixpackage manager with persistent data - Docker socket for interacting with docker inside the container
| ENV | VALUE | Description |
|---|---|---|
| PASSWORD | password | code-server auth password |
| PGID | 1000 | code-server user PGID |
| PUID | 1000 | code-server user PUID |
| TZ | Europe/London | timezone |
The PGID:PUID must be set to 1000:1000 to allow the code-server full access to the mounted Workspace folder
| Source | Target | Description |
|---|---|---|
| ./code-server/coder | /home/coder | Main user directory |
| ./code-server/nix | /nix | Directory for Nix system |
| ./Workspace | /home/coder/Workspace | User's workspace directory |
| /var/run/docker.sock | /var/run/docker.sock | Docker socket for interaction |
| ./nginx/certs | /etc/nginx/certs | Directory for Nginx certificates |
| ./nginx/nginx.conf | /etc/nginx/nginx.conf | Main Nginx configuration file |
nix-env is preinstalled with the home-manager, so you can install any packages into the container via nix.
If /nix and /home/coder are mounted, the installed packages will not disappear after restarting the container.
To install packages declaratively, you can edit the ~/.config/home-manager/home.nix file:
{config, pkgs, lib, ...}:
{
# enable quirks (e.g. set $XDG_DATA_DIRS environment variable) for non NixOS operating systems
targets.genericLinux.enable = true;
# enable proprietary software
nixpkgs.config.allowUnfree = true;
# install software
home.packages = with pkgs; [
# your packages here
nano
];
home.username = "coder";
home.homeDirectory = "/home/coder";
home.stateVersion = "24.11";
}Note
The first launch of code-server can be long due to the installation of nix-env.
