Deploying Docker Compose Microservices on a VPS Server Thailand

Running multiple applications on a single virtual server can become difficult when every service needs its own runtime, dependencies, and network configuration.
A Node.js API might require one environment, while a background processing service needs another. Add a database, reverse pro

Docker Compose provides a practical way to organize these services on a VPS server Thailand. It defines containers, networking, environment variables, and healthchecks in a configuration file.

For applications serving users in Thailand, a Bangkok-hosted VPS may also offer useful regional connectivity, depending on its network provider and routing.

This guide shows how to deploy a simple two-service Node.js application using Docker Compose, Nginx, and Let's Encrypt on an Ubuntu Linux VPS.

Why Use Docker Compose on a Thailand VPS?

Docker packages applications with their dependencies, reducing configuration differences between development and deployment environments.

Docker Compose builds on this by allowing multiple services to be managed together.

For example, a web application might include an API server, background worker, PostgreSQL database, and Redis cache.

Instead of installing every application component directly on the VPS operating system, each component can run in a separate container.

This provides several operational benefits:

  • Services can use different dependencies without conflicting.
  • Application configuration can be maintained in version control.
  • Containers can communicate through private Docker networks.
  • Deployments can be reproduced more consistently.
  • Individual services can be restarted and monitored separately.

Docker Compose is particularly useful for small and medium-sized applications that do not require a full container orchestration platform.

Step 1: Prepare the Linux VPS

This tutorial assumes Ubuntu 24.04 LTS running on a VPS with SSH access and sufficient resources for the intended application.

KVM virtualization is a common option for Linux VPS hosting. It provides virtual machines with their own guest operating systems, although actual CPU, memory, storage, and network performance depend on the hosting plan.

Before deploying, check the server:

uname -a

free -h

df -h

Update installed packages:

sudo apt update

sudo apt upgrade

Install Docker Engine and the Docker Compose plugin using Docker's official Ubuntu installation instructions:

Once installed, verify both tools:

docker --version

docker compose version

This guide uses sudo for Docker commands where necessary. Membership in the Docker group grants powerful host-level permissions and should not be given to untrusted users.

Step 2: Create a Simple Microservices Project

We'll deploy two HTTP services: an API and a background-jobs demonstration service.

Both use a small Node.js application, but each runs as a separate container with its own service name.

Create a project directory:

mkdir -p ~/thailand-microservices

cd ~/thailand-microservices

Create a file named app.js:

const http = require("node:http");

 

const service = process.env.SERVICE_NAME || "api";

 

const server = http.createServer((req, res) => {

  res.setHeader("Content-Type", "application/json");

 

  if (req.url === "/health") {

    res.writeHead(200);

    return res.end(JSON.stringify({ status: "ok" }));

  }

 

  res.writeHead(200);

  res.end(JSON.stringify({

    service,

    message: "Running on a Thailand VPS"

  }));

});

 

server.listen(3000, "0.0.0.0");

This example uses Node.js's built-in HTTP module, so no extra application packages are required.

Next, create a Dockerfile:

FROM node:22-alpine

 

WORKDIR /app

 

COPY --chown=node:node app.js ./

 

USER node

 

EXPOSE 3000

 

CMD ["node", "app.js"]

For production deployments, pin container images to reviewed versions or immutable digests and maintain a regular update process.

Step 3: Configure Docker Compose

Create compose.yaml inside the project directory.

services:

  api:

    build: .

    image: thailand-demo:local

    restart: unless-stopped

    environment:

      SERVICE_NAME: api

    ports:

      - "127.0.0.1:3000:3000"

    healthcheck:

      test:

        - CMD

        - node

        - -e

        - "require('node:http').get('http://127.0.0.1:3000/health',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"

      interval: 30s

      timeout: 5s

      retries: 3

      start_period: 10s

 

  jobs:

    image: thailand-demo:local

    restart: unless-stopped

    depends_on:

      api:

        condition: service_healthy

    environment:

      SERVICE_NAME: jobs

    ports:

      - "127.0.0.1:3001:3000"

    healthcheck:

      test:

        - CMD

        - node

        - -e

        - "require('node:http').get('http://127.0.0.1:3000/health',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"

      interval: 30s

      timeout: 5s

      retries: 3

The second service represents a separate application component, not an actual queue processor. A real background worker would need a job queue and worker-specific processing code.

Both containers share the default Compose network, but their application ports are published only to the VPS loopback interface.

This prevents ordinary direct public access to ports 3000 and 3001.

Validate and start the services:

sudo docker compose config

sudo docker compose up -d --build

sudo docker compose ps

You can test both locally on the VPS:

curl http://127.0.0.1:3000/

curl http://127.0.0.1:3001/

Docker Compose healthchecks help detect application problems. They do not, by themselves, guarantee automatic replacement of unhealthy containers.

Step 4: Configure Nginx as a Reverse Proxy

The next step is to make the services accessible through a domain instead of exposing their application ports.

Install Nginx:

sudo apt install nginx

Create a DNS A record pointing api.example.com to your VPS public IPv4 address.

Replace this example domain with one you control.

Create an Nginx configuration:

server {

    listen 80;

    server_name api.example.com;

 

    location /api/ {

        proxy_pass http://127.0.0.1:3000/;

        proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

    }

 

    location /jobs/ {

        proxy_pass http://127.0.0.1:3001/;

        proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

    }

}

Save it as:

/etc/nginx/sites-available/thailand-microservices

Enable the configuration:

sudo ln -s /etc/nginx/sites-available/thailand-microservices \

  /etc/nginx/sites-enabled/thailand-microservices

 

sudo nginx -t

sudo systemctl reload nginx

Before enabling this configuration, remove conflicting default virtual hosts if necessary.

The two services will be reachable through:

  • http://api.example.com/api/
  • http://api.example.com/jobs/

Nginx forwards incoming requests to the appropriate local container port.

Step 5: Add HTTPS with Let's Encrypt

Production-facing applications should use HTTPS to protect data transmitted between browsers and the server.

On Ubuntu, Certbot can work with Nginx to request and install certificates from Let's Encrypt.

Follow Ubuntu's current Certbot installation guidance, then request a certificate using:

sudo certbot --nginx -d api.example.com

The domain must resolve correctly, and inbound HTTP traffic on port 80 must be permitted for the normal HTTP validation process.

Certbot's Nginx integration can update the matching server configuration and enable HTTPS.

After certificate installation, test:

curl -I https://api.example.com/api/

Also verify certificate renewal using the method appropriate to your Certbot installation.

HTTPS protects network traffic, but it does not replace application authentication or API authorization.

Step 6: Monitor Container Health and Resource Usage

A container can be running while its application is failing.

Healthchecks provide an additional signal by periodically testing whether the application responds as expected.

Inspect current status:

sudo docker compose ps

Check logs:

sudo docker compose logs --tail=100

Monitor CPU and RAM:

sudo docker stats

For long-term operation, add monitoring for disk usage, service availability, backup success, and application errors.

Avoid storing important data only inside disposable container filesystems. Databases and uploaded application files need suitable persistent storage and backups.

Step 7: Understand Scaling and Storage Requirements

One advantage of a VPS is the ability to change its resource allocation when the hosting provider supports upgrades.

Vertical scaling increases available CPU, RAM, or storage resources.

For example, an API that becomes memory-constrained may benefit from additional RAM, while sustained compilation or processing workloads may need more CPU capacity.

NVMe-backed storage can help certain database and build workloads, but actual performance depends on the VPS storage system and its limits.

Changing a VPS plan may require a restart or migration. Check the provider's upgrade procedure before assuming that scaling will be interruption-free.

For Thailand-facing applications, also evaluate network latency from Bangkok, Chiang Mai, Phuket, and other target locations.

CyberPanel, HestiaCP, and Reverse Proxy Conflicts

CyberPanel and HestiaCP provide web hosting administration features, including domain and web server management.

They can be useful for traditional website hosting, but neither is required for a Docker Compose deployment.

This tutorial uses Nginx directly on the host.

If an existing control panel already manages ports 80 and 443, installing another independent Nginx instance can create conflicts.

Choose one clear reverse proxy and certificate-management approach rather than allowing multiple systems to compete for the same ports.

When Do You Need rDNS and PTR Records?

Reverse DNS maps an IP address back to a hostname through a PTR record.

For a conventional web API, correctly configured forward DNS and HTTPS certificates are the immediate priorities.

PTR records become especially relevant when operating mail services because email providers commonly examine reverse DNS and related sender-authentication settings.

PTR records are usually managed by the IP address owner or hosting provider.

Ask your VPS provider whether custom reverse DNS is supported if your application needs it.

Choosing a VPS Server Thailand for Docker Workloads

A suitable hosting plan should provide enough memory for all running containers, predictable CPU resources, adequate storage, and network connectivity that matches the application's users.

For developers comparing hosting options, Onlive Server provides information about VPS server Thailand configurations.

Before choosing a plan, verify its actual virtualization type, location, supported operating systems, storage allocation, backup options, and resource upgrade policies.

The right VPS configuration depends on what the containers actually run.

Final Thoughts

Docker Compose makes it easier to run multiple application services without manually managing separate runtime installations.

Nginx provides a single entry point, Let's Encrypt supports HTTPS, and container healthchecks make operational problems easier to detect.

For a Thailand VPS deployment, the remaining work is equally important: secure server access, monitor resources, protect persistent data, and test the network from the regions your application serves.

Start with a small, understandable setup. Expand the architecture when application requirements justify the additional complexity.

 


RishabhOnlive1

5 Blog Mensajes

Comentarios

¡Instala Camlive!

Instala la app para obtener la mejor experiencia, notificaciones instantáneas y mejor rendimiento.