Table of Contents
Run code-server in Docker to use a VS Code-style editor in your browser. Bind the service to the Linux host’s loopback address and use an SSH tunnel from another computer. This keeps the editor off public network interfaces while you configure it.
Start the container and keep files on the host
On a Linux host with Docker installed, create directories for settings, editor data and projects. This example uses Bash and the official code-server image. Run it as your normal account with the Docker access already configured on the host.
workspace_dir="$HOME/code-server-workspace"
mkdir -p "$workspace_dir"/{config,local,project}
chmod 700 "$workspace_dir/config"
docker run -d --name code-server
-p 127.0.0.1:8443:8080
-v "$workspace_dir/config:/home/coder/.config"
-v "$workspace_dir/local:/home/coder/.local"
-v "$workspace_dir/project:/home/coder/project"
-u "$(id -u):$(id -g)" -e "DOCKER_USER=$USER"
codercom/code-server:latestOpen http://127.0.0.1:8443 on the Linux host. The generated password is in ~/code-server-workspace/config/code-server/config.yaml. Keep that file private. Use docker logs code-server if the page does not start. The official installation guide also covers options outside Docker.



These screenshots show an earlier container command. Use the loopback binding and mounted directories above. For background on those settings, see the Docker and containers course.
Connect securely from another computer
From a computer that already has authorized SSH access to the Linux host, run ssh -N -L 8443:127.0.0.1:8443 user@linux-host. Replace user@linux-host with your account and hostname. Keep that session open, then visit http://127.0.0.1:8443 on the client. Keep authentication enabled. For other deployment options, follow Coder’s secure access guide.
Open a project and check the editor
In File > Open Folder, open /home/coder/project. Files created there persist in the host’s project directory. Use Explorer to browse, the editor to make changes, and Terminal > New Terminal to run commands in the container.



Use Extensions to install compatible tools from the available catalog. The gear menu opens settings and lets you choose a theme. Check compatibility before assuming a desktop VS Code extension can run on code-server.





Run a test program
Use Explorer to create hello.py in the project folder, save it, and enter this code:
for index in range(3):
print(f"Hello {index + 1}")


From a terminal in that folder, run python3 hello.py if Python is available. If it is missing, add it to a custom image so it remains available when you recreate the container. Confirm that the terminal prints three lines and that the file appears in the mounted project directory.

Reader Comments 0
Sign in with email or Google to join the discussion.