Docker

MeshCentral Docker – Deploy, Persist and Update Correctly

How to run the server in a container without ever losing its identity, data or agents.

MeshCentral multi-server layout with shared database and storage behind a load balancer

MeshCentral runs very comfortably inside a container, and for many administrators Docker is now the preferred way to deploy it. A container packages the right Node.js version together with the server, keeps the host system clean and makes moving or rebuilding the server a matter of copying a few folders. The convenience comes with its own rules, though, and the most serious problems people meet with containerised MeshCentral come from ignoring them. This article explains how the official image works, how to store data safely, how to handle certificates and reverse proxies, and how to update without losing anything.

Why Run MeshCentral in Docker?

There are practical reasons to prefer a container over a direct npm installation.

  • A known runtime. The image ships with a Node.js version the project has tested, so you are not at the mercy of your distribution's packages.
  • A clean host. Nothing is installed on the host apart from Docker itself, which makes the host easier to patch and rebuild.
  • Repeatable deployments. A compose file documents exactly how the server is configured and can be stored in version control.
  • Simple rollbacks. If a new release misbehaves, you can return to the previous image tag while keeping the same data.

The trade-off is an extra layer to understand. File permissions, networking and updates all behave slightly differently inside a container.

Choosing an Image

The MeshCentral project publishes an official image on the GitHub Container Registry. It is built from the project's own Dockerfile and is the safest starting point.

docker pull ghcr.io/ylianst/meshcentral:latest

Several community images also exist, some of which bundle MongoDB or add their own conveniences. They can be perfectly good, but they are maintained by third parties and may lag behind official releases. Whichever image you choose, check who maintains it, how often it is updated and whether its documentation explains every environment variable it reads.

Understanding the Container Layout

Inside the official image, the server lives under /opt/meshcentral. Three folders matter, and each must be stored outside the container on a persistent volume.

  • /opt/meshcentral/meshcentral-data holds config.json, the server's certificates and keys and, with the built-in database, the database files. It is the single most important folder.
  • /opt/meshcentral/meshcentral-files stores files uploaded to the server.
  • /opt/meshcentral/meshcentral-backups receives automatic backups.

A container's own file system is disposable. Anything written there disappears when the container is recreated, which happens on every update. If the data folder is not on a volume, an update will silently wipe the server's identity, and every agent will stop trusting it.

Treat the three folders as the server. The container is only the engine that runs them.

A Practical Compose File

Docker Compose is the clearest way to describe a MeshCentral deployment. The example below maps the standard ports, stores all three folders on the host and restarts the container automatically.

services:
  meshcentral:
    image: ghcr.io/ylianst/meshcentral:latest
    container_name: meshcentral
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    environment:
      - HOSTNAME=mesh.yourdomain.example
    volumes:
      - ./data:/opt/meshcentral/meshcentral-data
      - ./files:/opt/meshcentral/meshcentral-files
      - ./backups:/opt/meshcentral/meshcentral-backups

Start it with docker compose up -d and follow the logs with docker compose logs -f. On the first start, the container generates config.json and certificates inside the data volume. From then on, the values in config.json take effect, so it is worth reading the generated file and adjusting it rather than relying only on environment variables.

Environment Variables versus config.json

The official image can read a number of environment variables on its first start, covering details such as the hostname, whether the server sits behind a reverse proxy and whether new accounts may register. These are a convenient way to bootstrap a fresh server. The exact names and behaviour are documented alongside the image and can change between releases, so check that documentation rather than copying variables from old blog posts.

Once the data folder exists, config.json is the authoritative record of the server's settings. Many administrators prefer to edit config.json directly for anything beyond the basics, because it supports every option the server understands, including authentication strategies, database connections and automatic backup schedules.

Choosing a Database in a Container Setup

For a small installation, the built-in database stored in the data volume is enough. For larger fleets, run the database as its own container alongside MeshCentral and connect the two on a private Docker network. A MongoDB example looks like this:

services:
  mongodb:
    image: mongo:7
    restart: unless-stopped
    volumes:
      - ./mongo:/data/db
  meshcentral:
    image: ghcr.io/ylianst/meshcentral:latest
    restart: unless-stopped
    depends_on:
      - mongodb
    ports:
      - "443:443"
    volumes:
      - ./data:/opt/meshcentral/meshcentral-data
      - ./files:/opt/meshcentral/meshcentral-files
      - ./backups:/opt/meshcentral/meshcentral-backups

Then point MeshCentral at the database in config.json with a connection string that uses the service name as the host, for example "mongoDb": "mongodb://mongodb:27017/meshcentral". Never publish the database port to the internet; only MeshCentral needs to reach it.

Certificates and Reverse Proxies

A containerised server faces the same certificate choices as any other installation. You can let MeshCentral obtain a Let's Encrypt certificate itself, which requires port 80 to reach the container, or you can place a reverse proxy such as Traefik, Caddy, NGINX or HAProxy in front of it.

When a proxy terminates TLS, two adjustments are essential. MeshCentral must be told that TLS is being offloaded, and the agents must be able to verify the certificate that the proxy presents. In config.json this usually means setting tlsOffload to the proxy's address, setting aliasPort to 443 so that MeshCentral generates correct links, and providing the proxy's certificate through the certUrl option or by placing it in the data folder. The proxy must also forward WebSocket upgrades, because agents and remote desktop sessions depend on them.

If the proxy runs in another container, attach both to the same Docker network and let MeshCentral listen only on that network rather than on the host's public interface.

Updating the Container Correctly

This is the rule most often broken. MeshCentral has a built-in self-update feature in its web interface, but it must not be used inside a container. The update would modify files inside the container's temporary layer and would be lost or, worse, leave the container in an inconsistent state the next time it is recreated.

Update the Docker way instead:

docker compose pull
docker compose up -d

Before pulling, take a backup of the three folders, and read the release notes. Pinning a specific version tag rather than latest gives you control over exactly when updates happen and makes rollbacks precise. When a security release is announced, however, apply it promptly; servers running known-vulnerable versions are actively targeted.

Backups in a Containerised Deployment

Because all state lives in host folders, backing up a Docker deployment is refreshingly simple.

  • Enable MeshCentral's automatic backups in config.json so that the server writes regular archives to the backups volume.
  • Copy the backups folder to a different machine or storage service on a schedule.
  • For an external database, use the database's own dump tools in addition to MeshCentral's backups.
  • Periodically test a restore on a separate host, because an untested backup is only a hope.

Security Considerations Specific to Docker

Containers add isolation, but they do not make a server secure by themselves.

  • Run the host operating system with automatic security updates where practical.
  • Publish only the ports MeshCentral genuinely needs.
  • Keep the Docker socket out of any container that does not need it.
  • Restrict who can run Docker commands on the host, since Docker access is effectively root access.
  • Enable two-factor authentication for every administrator account and disable open registration.

Troubleshooting Common Docker Problems

Agents stop connecting after an update

This almost always means the data folder was not persistent and the server generated new certificates. Restore the previous data folder from a backup and the agents will reconnect.

Permission denied errors in the logs

The process inside the container cannot write to a host folder. Check ownership and permissions of the mapped directories, particularly if you created them manually as root.

Browser connects but agents do not

The certificate the agents see does not match the one MeshCentral expects, usually because a reverse proxy is terminating TLS without MeshCentral being told about it. Review the tlsOffload and certUrl settings.

Remote desktop freezes behind a proxy

The proxy is not forwarding WebSocket connections correctly or is closing them after a short timeout. Enable WebSocket support and lengthen idle timeouts.

Planning the Host for a Container Deployment

A container does not remove the need to size and secure the machine underneath it. Before deploying, decide how much processor capacity, memory and disk space the host will offer, and remember that MeshCentral is only one consumer. If a database container runs beside it, that database needs its own share of memory, and its volume will grow with every event and device record. Session recordings, if enabled, can grow faster than anything else.

Think about ports at the same time. The server needs HTTPS for browsers and agents, HTTP if it obtains its own Let's Encrypt certificates, and port 4433 only if Intel AMT devices will connect to it directly. Publish nothing else. When a reverse proxy is part of the design, the MeshCentral container may not need to publish any ports to the host at all, because the proxy can reach it over the private Docker network.

Finally, place the compose file and the three data folders together in one clearly named directory. That single directory, plus the image tag, describes the entire server, which makes moving it to new hardware or handing it over to a colleague refreshingly straightforward.

Frequently Asked Questions

Yes. The project publishes an image on the GitHub Container Registry, built from its own Dockerfile. Community images also exist but are maintained independently.

No. Update by pulling a newer image and recreating the container. The built-in updater changes files inside the container that will not persist.

The data, files and backups folders under /opt/meshcentral. The data folder is critical because it contains the server's certificates and keys.

Docker Desktop can run the Linux image on Windows, which is fine for testing. For a production server, a Linux host is the more common and predictable choice.

Yes. Add a database service, keep it on the internal network and point MeshCentral at it with a connection string in config.json.

Stop the container, restore the data folder from the backup taken before the update and start the container with the previous image tag.

Conclusion

MeshCentral and Docker make a strong combination when the container is treated as a replaceable engine and the three data folders are treated as the real server. Use the official image, store data on persistent volumes, configure certificates and reverse proxies deliberately, and update by pulling new images rather than through the web interface. Follow those principles and a containerised server becomes one of the easiest MeshCentral deployments to maintain, back up and move.