This guide walks you through setting up a Docker-based development environment on a VPS, complete with a cloud IDE (VS Code Server) so you can code from any browser. You’ll get a reproducible setup, isolated containers for each project, and a persistent workspace — all on your own server.
What You’ll Need
- A VPS with at least 2GB RAM (4GB recommended), running Ubuntu 22.04 or 24.04 (or Debian 11/12).
- SSH access to the server (root or a user with sudo privileges).
- A domain name (optional but recommended for HTTPS). If you don’t have one, you can use the server’s IP address for HTTP.
- Basic familiarity with the command line.
Step-by-Step
- Connect to your VPS via SSH:
ssh user@your_server_ip - Update the system and install prerequisites:
sudo apt update && sudo apt upgrade -y sudo apt install -y curl git ufw
- Install Docker using the official convenience script (or follow the manual install for your distro):
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh
- Add your user to the docker group so you can run docker without sudo:
sudo usermod -aG docker $USER newgrp docker
- Install Docker Compose plugin (usually included with the convenience script, but verify):
docker compose version
If not present, install it via
sudo apt install docker-compose-plugin. - Create a directory for your projects and set permissions:
mkdir -p ~/projects cd ~/projects
- Create a docker-compose.yml for the cloud IDE (VS Code Server). Use this as a starting point:
services: code-server: image: lscr.io/linuxserver/code-server:latest container_name: code-server environment: - PUID=1000 - PGID=1000 - TZ=Etc/UTC - PASSWORD=your_strong_password - DEFAULT_WORKSPACE=/config/workspace volumes: - ./config:/config - ./projects:/config/workspace ports: - "8443:8443" restart: unless-stoppedReplace
your_strong_passwordwith a real password. The./projectsfolder will be your workspace. - Start the IDE container:
docker compose up -d
- Open the IDE in your browser at
http://your_server_ip:8443. Log in with the password you set. - Set up a reverse proxy with Nginx (optional but recommended for HTTPS and a clean URL). Install Nginx:
sudo apt install -y nginx
Create a config file for your domain:
sudo nano /etc/nginx/sites-available/code-server
Add:
server { listen 80; server_name your_domain.com; location / { proxy_pass http://localhost:8443; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Accept-Encoding gzip; } }Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
- Add HTTPS with Let’s Encrypt using Certbot:
sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d your_domain.com
Follow the prompts. Your IDE will now be accessible at
https://your_domain.com. - Create a project-specific Dockerfile (optional but useful). For example, a Node.js environment:
mkdir -p ~/projects/myapp cd ~/projects/myapp nano Dockerfile
Add:
FROM node:20 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . CMD ["npm", "start"]
Now you can build and run this container alongside your IDE.
- Set up a firewall to only allow necessary ports:
sudo ufw allow OpenSSH sudo ufw allow 'Nginx Full' sudo ufw enable
If you’re not using Nginx, allow port 8443 instead.
Common Mistakes
- Forgetting to add your user to the docker group — you’ll have to use sudo for every docker command, which can cause permission issues in scripts.
- Using a weak password for code-server — anyone can access your IDE if it’s exposed to the internet. Use a strong password or better, set up OAuth.
- Not enabling the firewall — leaving port 8443 open to the world is a security risk. Use a reverse proxy and firewall rules.
- Mounting the wrong volume path — if you mount
./projectsto/config/workspace, make sure the IDE’s default workspace matches that path, otherwise you’ll see an empty folder. - Ignoring container logs — if something fails, check
docker logs code-serverfor errors.
Tips
- Use a dedicated non-root user for Docker and your projects. This limits the blast radius if a container is compromised.
- Persist your Docker volumes — always use named volumes or bind mounts to keep data across container recreations.
- Set up a swap file if your VPS has low RAM. This prevents OOM kills when running multiple containers.
- Use a domain name — it makes HTTPS and certificates much easier, and you avoid browser warnings about insecure connections.
- Regularly update your base images — run
docker compose pullanddocker compose up -dto get security patches.
Troubleshooting
- Can’t access the IDE at port 8443 — Check if the container is running (
docker ps). If it’s not, check logs (docker logs code-server). Also verify the firewall allows the port (if you didn’t set up Nginx). - HTTPS certificate fails — Make sure your domain resolves to your VPS IP. Also check that port 80 is open in the firewall for the HTTP-01 challenge.
- Docker permission denied — Run
newgrp dockerafter adding your user, or log out and back in. - IDE shows an empty workspace — Check that the volume mount path matches the DEFAULT_WORKSPACE environment variable. Also verify the host folder exists and has correct permissions.
- Container keeps restarting — Look at the logs. Often it’s a misconfigured environment variable or a permission issue on the mounted volume.
Frequently Asked Questions
Can I use this setup for multiple projects?
Yes. Each project can have its own directory under ~/projects, and you can run separate containers for each. The IDE can open any folder in the workspace.
Is it safe to expose a cloud IDE to the internet?
It’s safer than exposing a raw SSH port, but you should still use a strong password, enable HTTPS, and consider adding a VPN or IP whitelist for extra security.
What if I need a database for my project?
Add a database service (like PostgreSQL or MySQL) to your docker-compose.yml. You can link it to your app container via Docker’s internal network.
Can I use the IDE for Python, Go, or other languages?
Yes. VS Code Server supports any language with extensions. You can install extensions from the IDE’s Extensions panel, or pre-install them in the Dockerfile.
How do I back up my work?
Since your projects are stored in ~/projects on the VPS, you can use rsync, git, or a cloud backup service to copy that folder to your local machine or another server.
What if I want to use a different cloud IDE, like Eclipse Theia?
The same steps apply. Just replace the image in docker-compose with the one for Theia (e.g., theiaide/theia), and adjust the port and volume paths accordingly.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Business partnership due diligence checklist what to verify before you sign?
- Does the FCC Protect Internet Privacy?
- Disaster Robbers Codes? Meaning & Origin
- Repair a Disk with Mac Disk Utility
- Avoid Vendor Lock-In: Cloud Provider Strategy
- Secure GitHub Accounts & Repos Against Malicious Code