There’s already plenty of code-server docker setups out there, what’s the point of this? Well, every single alternative I found was either focused on a specific development environment or it had too much going on, with bunch layers of stuff I was never going to use.
I wanted something barebones and simple, there’s no custom base images, no extra features you’ll never use. The whole image consists of a Dockerfile and entrypoint.sh, that’s it.
The idea behind this setup is running code-server behind Traefik reverse proxy with docker extension installed on vscode. From code-server you’ll be able to spin up any kind of container and develop without ever installing node, python or whatever else on your system.
The guide assumes you already know basics of docker and docker compose. The reason Traefik and code-server compose files are split up, is to keep things modular in case you already run Traefik on your system.
- Domain
- Docker
- Docker Compose (comes with Docker Engine now)
You can skip this part in case you already have Traefik running. However, it may be still useful to look at the configuration on the repo in case you're having issues.
Clone repository
git clone https://github.com/EdyTheCow/docker-code-server.git
Set correct acme.json permissions
Navigate to _base/data/traefik/
and run
sudo chmod 600 acme.json
Setup basic auth
Basic auth provides extra layer of security on top of code-server authentication.
Generate htpasswd and copy it to _base/data/traefik/.htpasswd
Start docker compose
Inside of _base/compose
run
docker-compose up -d
Configure variables
Navigate to code-server/compose/.env
and set these variables
Variable | Description |
---|---|
DOMAIN | Domain you're going to use to access the code-server |
PASSWORD | Password for code-server |
Configure container user
The container itself runs a non-root user you'll have to specify in code-server/compose/docker-compose.yml
. In order to pass docker cli permissions on to container you'll have to specify your docker group ID.
Example: user: "1000:999"
1000 being your user ID and 999 being your docker group ID.
DOCKER_USER variable
The DOCKER_USER=${USER}
variable is meant to take your current user's username and pass it on to the container. Meaning you'll have your username from host automatically setup inside of container. You can however remove the variable from docker-compose.yml
alltogether, username coder
will be used by default instead.
Start docker compose
docker-compose up -d
You can now navigate to DOMAIN
you set earlier to access code-server and open terminal to continue setup of zsh and Oh My Zsh.
By default image installs zsh and Oh My Zsh with a powerlevel10k theme, so you'll have a fancy terminal inside of coder-server! These steps can be skipped if you prefer default look or a different theme.
Install font for powerlevel10k theme
Download the font, install it and change it in code-server. You can follow the Visual Studio Code guide provided in the same link as the font.
Installing font for Oh My Zsh theme https://github.com/romkatv/powerlevel10k#manual-font-installation
Open .zshrc and change theme to
ZSH_THEME="powerlevel10k/powerlevel10k"
You'll be asked to go through a setup process once relaunch your terminal.
You can now install Docker and any other extensions you might want.
- None so far 👀