Docker Hosting

Narrated with the voice of Edi AI AI developed by ServerHost

Each feature in your account, step by step, with examples you can copy. Open a section to read it.

First steps: your first project

Your server runs Docker with Compose. You describe the containers in docker-compose.yml, press „Save and run”, and the server builds and starts them. You can start from the editor in your account (below) or from git (see „Deploy from git”).

  1. Open the project

    In the Project box press Edit. The editor already holds a small example (nginx with a volume).

  2. Write or paste docker-compose.yml

    Each service is a container. Use image: for a ready image or build: for a Dockerfile from the project.

  3. Press „Check”

    The server checks the project with the same rules it uses when running it, without changing anything. The problems appear in a list, with the service name.

  4. Press „Save and run”

    The version is saved (the last 10 stay in the history) and applied on the server: images are downloaded or built, then the containers start. The result and the docker compose output appear under the editor.

  5. Give it a domain

    In the Domains box add a domain pointing to the service and the port inside the container (here web, port 80). The HTTPS certificate is issued automatically.

docker-compose.yml
services:
  web:
    image: nginx:alpine
    volumes:
      - site:/usr/share/nginx/html
    deploy:
      resources:
        limits: {cpus: "0.5", memory: 256M}
    restart: unless-stopped

volumes:
  site: {}
  • Put restart: unless-stopped on every service: the containers start again after a server restart. A service without a restart policy gets on-failure from the server: it is restarted when it stops with an error or runs out of memory.
  • Set CPU and memory limits (deploy.resources.limits): one container cannot then take the whole server.
Containers

The Containers box shows how many containers run out of how many your service includes. Manage opens the list.

  1. Read the state

    Each container shows: running or stopped (with the exit code or „out of memory”), the health check (healthy, unhealthy, starting, no health check), restarts, CPU and memory used out of its limit, and its ports.

  2. Understand the port labels

    public: reachable from the Internet; blocked by firewall: published, but not opened (press „open” to open it); private only: reachable only on the private network and through your VPN; server only: published on 127.0.0.1, reachable only from the server itself; internal: only between containers.

  3. Start, stop, restart

    The buttons on each container act immediately, only on that container.

  4. Delete

    Deletes the container, never its volumes. It comes back at the next „Save and run” while the service is still in docker-compose.yml; to remove it for good, delete or comment out the service in docker-compose.yml.

Health check (docker-compose.yml)
services:
  api:
    build: .
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/health"]
      interval: 30s
      timeout: 5s
      retries: 3
    restart: unless-stopped
  • Every container counts towards the containers included in your service (services × replicas), except our HTTPS proxy. A compose that starts more is refused at „Check”; increase the number from Allocated resources → Edit.
  • A health check lets us warn you when the application stops answering, even if the container is still running.
Volumes and quotas

Data that must survive a restart or a new version goes into volumes. Each volume has its own quota on the data disk, set by you.

  1. Declare the volume

    Add it under volumes: at the end of docker-compose.yml and mount it in the service. At the first run it receives a quota of 5 GB (or what is left, if less). With less than 1 GB unallocated, the run stops: reduce the quotas of other volumes or increase the storage.

  2. Change the quota

    In Volumes → Edit, write the quota in GB next to each volume. The sum appears in red if it goes above the maximum; press „Save quotas”.

  3. Watch the usage

    Each volume shows how much it uses out of its quota. At 90% you see a warning and receive an email (once, until it drops below 85%).

  4. Delete an unused volume

    A volume that no container uses shows „Delete”. The data is deleted for good; if the volume is still in docker-compose.yml, the next run creates it again, empty.

A database with a volume
services:
  db:
    image: postgres:17-alpine
    environment:
      POSTGRES_PASSWORD: ${DB_PASS}
    volumes:
      - pgdata:/var/lib/postgresql/data

volumes:
  pgdata: {}
A project file mounted read-only
services:
  web:
    image: nginx:alpine
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - site:/usr/share/nginx/html

volumes:
  site: {}
  • The quotas together can reach at most 90% of the data disk, and 6 GB always stay free for images and builds (20 GB disk: 14 GB for volumes). Each quota is at least 64 MB and at least what the volume already uses.
  • Project files (./file) can be mounted only read-only, with :ro. Everything the application writes goes into volumes.
  • More storage: Allocated resources → Edit. The data disk only grows.
  • With Hybrid Storage (SSD-NVMe, from Allocated resources → Edit) a volume can sit on the SSD-NVMe disk: put the label svh.disk: ssd on the volume in docker-compose.yml (volumes: { pgdata: { labels: { svh.disk: ssd } } }) and it is created there, or move an existing volume with Move to SSD-NVMe / Move to HDD Cluster. Moving copies the data to the other disk: the containers that use the volume stop while the copy runs, then start again. Each disk has its own quota limit; images and builds stay on HDD Cluster. Hybrid Storage can be removed only after all volumes are back on HDD Cluster.
Project: editor, files, .env, versions

The project is docker-compose.yml, .env and your files (Dockerfiles, configurations, small pages). Everything is kept in your account, with the last 10 versions.

  1. Add files

    Upload files (several at once, at most 512 KB each) or New file with its path, e.g. web/Dockerfile. A file can be renamed or removed from the editor.

  2. Keep the secrets in .env

    Write passwords and keys in .env and use them in docker-compose.yml as ${NAME}, or give the whole file to a service with env_file: ./.env.

  3. Check, then run

    „Check” shows the problems without changing anything; „Save and run” saves a new version and applies it.

  4. Go back to a version

    Choose a version from the list and press Revert to this version: it is applied right away, as a new version. To change it first, press Load in editor; it is applied only when you press „Save and run”.

.env
DB_PASS=o-parola-lunga-si-unica
APP_KEY=cheia-aplicatiei
web/Dockerfile
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
  • Not allowed, because they would give access to the whole server: privileged, cap_add, devices, network_mode / pid / ipc host, mounts of server folders or of the Docker socket, other logging drivers, external volumes and networks, build with network host.
  • Server ports 22, 80 and 443 are reserved (SSH and our proxy). For web applications use a domain instead of a published port.
  • After every run (from the account or from git) the server checks the containers: healthy (with a health check), or running for one minute without restarts, or finished with code 0. If the new version does not pass within 5 minutes, the server starts the last successful version again. The data in the volumes does not go back (a database migration stays done).
  • At most 60 files, 512 KB each, 4 MB in total. For larger projects use deploy from git.
  • A version larger than about 600 KB is not kept in the history: only the current one remains.
Domains (HTTPS)

Our proxy sends each domain to a service and a port inside the container. The HTTPS certificate (Let's Encrypt) is issued and renewed automatically. You do not need to publish ports 80 or 443.

  1. Point the DNS

    At your domain registrar, add an A record for the domain (e.g. app.example.com) with the value SERVER_IP.

  2. Add the domain

    In Domains → Edit: write the domain, choose the service and the port inside the container (e.g. 80 for nginx, 3000 for Node.js), press Add.

  3. Wait for the certificate

    While the DNS does not point to the server, the domain has a temporary certificate. Once the DNS is correct, the Let's Encrypt certificate is issued within minutes (checked every 5 minutes).

  4. Security per domain

    Press Security next to the domain: Access addresses only (the whole domain opens only from your access addresses and VPN), Content-Security-Policy (report only or enforced, with the allowed external domains).

  • Each domain can belong to a single ServerHost service. At most 20 domains per server.
  • The security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, HSTS) are added automatically, only if your application does not send them already.
Ports open to the Internet

For services that are not web (MQTT, game servers, a database you reach from outside), publish the port in docker-compose.yml and open it from your account.

  1. Publish the port

    In docker-compose.yml: ports: ["1883:1883"] (server port : container port).

  2. Open it in the firewall

    In Security → Edit, under „Ports open to the Internet”, write the port, choose TCP or UDP and press Open. You can also press „open” directly on a port shown as „blocked by firewall” in the container list.

  3. Close it

    Press × next to the port: it stays reachable only through your VPN.

A published port (docker-compose.yml)
services:
  mqtt:
    image: eclipse-mosquitto:2
    ports:
      - "1883:1883"
  • A published port that you do not open stays closed to the Internet, but reachable through your VPN: useful for databases and admin panels.
  • Country blocking applies to the opened ports as well.
Logs

Each container writes to stdout and stderr. You can follow them live, and you can keep them on disk for the services you choose.

  1. Follow live

    In Logs → View live choose the container (or press Logs on a container). New lines appear every 2 seconds; stderr lines are red. Choose stdout or stderr only from the list; uncheck „follow” to stop reading new lines.

  2. Keep them (persistent logs)

    Under „Persistent logs” tick the services and the number of days (1-90), then save. The logs are written to the app__logs volume, rotated daily and compressed.

  3. Manage the space

    The app__logs volume starts with 1 GB and appears with the other volumes: increase its quota there if you keep many days.

  • By default (without persistent logs) each container keeps only a small rotating buffer: older lines are lost.
Security

The same protections as for web hosting, at the server level.

  1. Access addresses

    Your IP addresses (or DDNS names) from which the protected domains open: the ones with „Access addresses only”.

  2. VPN access

    With VPN on, your VPN users reach the server from anywhere, including the ports that are not opened to the Internet.

  3. Blocked countries

    Traffic from and to the checked countries is blocked by the firewall, on all ports, containers included. Save the countries: the firewall is updated within minutes.

  • The firewall is always on: from the Internet only 80/443 (for the proxy) and the ports you open are reachable. Port 22 (SSH) opens only for your access addresses and, with deploy from git, for the CI addresses.
Deploy from git

On every push, the CI of your repository sends the project to the server. The server does not connect to your repository and needs no deploy key.

  1. Choose git

    In Code deploy → Edit choose Git (deploy from CI) and the git service: ServerHost GitLab (allowed automatically) or another one (GitHub, GitLab.com, your own runner: write the CI address, port 22 opens only for it). Press Save the project source.

  2. Save the CI key

    Press Copy key and save it in the repository as a protected CI variable (secret) named SVH_DEPLOY_KEY. The private key is shown for 24 hours only; after that you can generate a new one.

  3. Add the CI configuration

    Copy the example for your git service into the repository. docker-compose.yml (or compose.yaml) must be in the root of the repository.

  4. Keep .env in the account

    The secrets stay in your account, in Project → .env (in git mode the editor shows only .env). A .env from the repository is ignored.

  5. Push

    The CI job sends the code, the server checks it (the same rules as the editor) and runs it. The job is green if the project started and passed the health check, and red with the exact reason if not (the server then starts the last successful version again). Code deploy shows the last deploy (commit, result, output) and the previous ones.

  6. Go back to a previous version

    The repository is the source of the project, so you go back from your CI, by running again the deploy of the commit you want: in GitLab, Build → Pipelines, the pipeline of that commit, then Retry on the deploy job; in GitHub, Actions, the run of that commit, then Re-run all jobs. The job sends that commit again (git archive HEAD is the commit of the pipeline). In the account, Revert to this version is available only with the editor in your account.

.gitlab-ci.yml (GitLab)
deploy:
  stage: deploy
  image: alpine:3
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  script:
    - apk add --no-cache git openssh-client
    - mkdir -p ~/.ssh && echo "$SVH_DEPLOY_KEY" > ~/.ssh/ci-svh && chmod 600 ~/.ssh/ci-svh
    - git archive --format=tar HEAD > app.tar
    - ssh -i ~/.ssh/ci-svh -o StrictHostKeyChecking=accept-new svhdeploy@SERVER_IP
        deploy "$(sha256sum app.tar | cut -d' ' -f1)" < app.tar
.github/workflows/deploy.yml (GitHub Actions)
name: deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy
        env:
          SVH_DEPLOY_KEY: ${{ secrets.SVH_DEPLOY_KEY }}
        run: |
          mkdir -p ~/.ssh && echo "$SVH_DEPLOY_KEY" > ~/.ssh/ci-svh && chmod 600 ~/.ssh/ci-svh
          git archive --format=tar HEAD > app.tar
          ssh -i ~/.ssh/ci-svh -o StrictHostKeyChecking=accept-new svhdeploy@SERVER_IP \
            deploy "$(sha256sum app.tar | cut -d' ' -f1)" < app.tar
By hand, from your computer (with the same key)
git archive --format=tar HEAD > app.tar
ssh -i ~/.ssh/ci-svh svhdeploy@SERVER_IP deploy "$(sha256sum app.tar | cut -d' ' -f1)" < app.tar
  • Refused, with nothing changed: an archive that did not arrive complete (SHA-256), symbolic links in the repository, a project that does not pass the checks. Files removed from the repository are deleted from the server at the next deploy; the volumes are not touched.
  • At most 512 MB per archive and 20,000 files. Do not commit node_modules, vendor or build output: they are built on the server, from the Dockerfile.
  • Back to the editor: choose Editor in your account; the CI key stops working and „Save and run” puts the project from the editor back.
Example: a Node.js application

A Node.js application (Express, Fastify, NestJS) with PostgreSQL, deployed from git. The dependencies are installed on the server, at build time.

  1. Add the Dockerfile and .dockerignore

    In the root of the repository, next to package.json.

  2. Add docker-compose.yml

    The app service is built from the Dockerfile; the database keeps its data in the pgdata volume.

  3. Write .env in the account

    E.g. DB_PASS=... and DATABASE_URL=postgres://postgres:...@db:5432/postgres (the database is reachable by the service name, db).

  4. Push, then add the domain

    After the first successful deploy, add the domain pointing to app, port 3000.

Dockerfile
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV NODE_ENV=production
EXPOSE 3000
USER node
CMD ["node", "server.js"]
.dockerignore
node_modules
.git
.env
npm-debug.log
docker-compose.yml
services:
  app:
    build: .
    env_file: ./.env
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/health"]
      interval: 30s
    deploy:
      resources:
        limits: {cpus: "1", memory: 512M}
    restart: unless-stopped

  db:
    image: postgres:17-alpine
    environment:
      POSTGRES_PASSWORD: ${DB_PASS}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: unless-stopped

volumes:
  pgdata: {}
Dockerfile for Next.js (build in two stages)
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/package*.json ./
RUN npm ci --omit=dev
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
EXPOSE 3000
USER node
CMD ["npx", "next", "start", "-p", "3000"]
  • The application must listen on 0.0.0.0, not on localhost, for the proxy to reach it.
  • The build uses the CPU and memory of your server; a large Next.js build may need 2 GB of RAM.
  • Two containers here (app and db): both count towards the containers included in your service.
Example: a Python application (FastAPI) with a worker

An API in Python (FastAPI) with PostgreSQL, Redis and a worker for background jobs, deployed from git. The API and the worker are built from the same code.

  1. Add the Dockerfile, .dockerignore and requirements.txt

    In the root of the repository, next to main.py (the API) and worker.py (the jobs).

  2. Add docker-compose.yml

    The api and worker services are built from the same Dockerfile; worker runs another command (python -m worker). PostgreSQL keeps its data in the pgdata volume; Redis keeps the job queue only in memory.

  3. Write .env in the account

    E.g. DB_PASS=..., DATABASE_URL=postgresql://postgres:...@db:5432/postgres and REDIS_URL=redis://redis:6379/0 (the other services are reachable by name).

  4. Push, then add the domain

    After the first successful deploy, add the domain pointing to api, port 8000. The worker, the database and Redis need no domain: they are reachable only between containers.

Dockerfile
FROM python:3.13-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN useradd -r -u 10001 app
USER app
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]
.dockerignore
__pycache__
.venv
.git
.env
requirements.txt
fastapi
uvicorn[standard]
psycopg[binary]
redis
docker-compose.yml
services:
  api:
    build: .
    env_file: ./.env
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"]
      interval: 30s
    depends_on: [db, redis]
    deploy:
      resources:
        limits: {cpus: "1", memory: 512M}
    restart: unless-stopped

  worker:
    build: .
    command: ["python", "-m", "worker"]
    env_file: ./.env
    depends_on: [db, redis]
    deploy:
      resources:
        limits: {cpus: "0.5", memory: 256M}
    restart: unless-stopped

  db:
    image: postgres:17-alpine
    environment:
      POSTGRES_PASSWORD: ${DB_PASS}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    command: ["redis-server", "--save", "", "--appendonly", "no"]
    restart: unless-stopped

volumes:
  pgdata: {}
  • Uvicorn listens on 0.0.0.0, not on localhost, for the proxy to reach it. The /health address used by the health check is written by you, in the API.
  • Four containers here (api, worker, db, redis): all count towards the containers included in your service.
  • For WordPress or other PHP sites use Web hosting: it has the WordPress protections, the page cache and WebP built in.
Email alerts

We write to you by email (and in the Messages of your account) when something needs your attention. Each problem is sent once and rearmed when it is gone.

  1. Volumes and data disk

    At 90% of a volume quota or of the data disk.

  2. Unhealthy container

    When the health check fails.

  3. Restart loop

    When a container restarts again and again (at least 3 times between two checks).

  4. Unexpected stop

    When a running container stops with an error or runs out of memory, without you stopping it from the account.

  • The checks run every 5 minutes.