{"id":484,"date":"2026-06-22T06:04:46","date_gmt":"2026-06-22T06:04:46","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=484"},"modified":"2026-06-22T06:04:46","modified_gmt":"2026-06-22T06:04:46","slug":"docker-compose-vps-multi-container-minimal-ram","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/","title":{"rendered":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Running multiple containers on a budget VPS (1\u20132 GB RAM) requires careful resource planning. Docker Compose makes orchestration straightforward, but default configurations can quickly exhaust memory. This guide shows how to deploy a full multi-container stack \u2014 Nginx reverse proxy, PHP-FPM, PostgreSQL, and Redis \u2014 on a VPS with only 1 GB RAM, using Docker Compose resource limits, health checks, and Alpine-based images.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding why resource efficiency matters is the first step. <a href=\"https:\/\/virtualserversvps.com\/#why\">Check our VPS comparison table<\/a> for plans that balance RAM and cost for containerized workloads.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Docker Compose on a Budget VPS?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Docker Compose allows you to define and run multi-container applications with a single <code>docker-compose.yml<\/code> file. On a budget VPS, the challenge is fitting all services within limited RAM without swapping. Key strategies include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Using Alpine-based images (20\u201350 MB vs. 200\u2013600 MB for Debian\/Ubuntu base)<\/li><li>Setting explicit <code>mem_limit<\/code> and <code>mem_reservation<\/code> per service<\/li><li>Disabling unnecessary services (e.g., PHP opcache file cache if using Redis)<\/li><li>Sharing volumes and networks to reduce overhead<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install Docker and Docker Compose<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On a fresh Ubuntu 22.04 VPS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y docker.io docker-compose-v2\nsudo systemctl enable --now docker\ndocker --version\ndocker compose version<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Define the Minimal Stack<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s a <code>docker-compose.yml<\/code> configured for a 1 GB RAM VPS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.8'\n\nservices:\n  nginx:\n    image: nginx:alpine\n    mem_limit: 128m\n    mem_reservation: 64m\n    ports:\n      - \"80:80\"\n    volumes:\n      - .\/app:\/var\/www\/html\n      - .\/nginx.conf:\/etc\/nginx\/conf.d\/default.conf\n    depends_on:\n      php:\n        condition: service_healthy\n    networks:\n      - app-net\n\n  php:\n    image: php:8.3-fpm-alpine\n    mem_limit: 256m\n    mem_reservation: 128m\n    volumes:\n      - .\/app:\/var\/www\/html\n    environment:\n      - PHP_MEMORY_LIMIT=128M\n      - PHP_MAX_EXECUTION_TIME=30\n    healthcheck:\n      test: [\"CMD\", \"php-fpm\", \"-t\"]\n      interval: 10s\n      timeout: 5s\n      retries: 3\n    networks:\n      - app-net\n\n  postgres:\n    image: postgres:16-alpine\n    mem_limit: 256m\n    mem_reservation: 128m\n    environment:\n      POSTGRES_DB: app\n      POSTGRES_USER: app\n      POSTGRES_PASSWORD: changeme\n      POSTGRES_SHARED_BUFFERS: 64MB\n      POSTGRES_EFFECTIVE_CACHE_SIZE: 192MB\n    volumes:\n      - pgdata:\/var\/lib\/postgresql\/data\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U app\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n    networks:\n      - app-net\n\n  redis:\n    image: redis:7-alpine\n    mem_limit: 64m\n    mem_reservation: 32m\n    command: redis-server --maxmemory 48mb --maxmemory-policy allkeys-lru\n    healthcheck:\n      test: [\"CMD\", \"redis-cli\", \"ping\"]\n      interval: 10s\n      timeout: 3s\n    networks:\n      - app-net\n\nvolumes:\n  pgdata:\n\nnetworks:\n  app-net:\n    driver: bridge<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Total reserved memory: 384 MB | Total limit: 704 MB.<\/strong> This leaves ~300 MB for the kernel, Docker daemon, and headroom \u2014 well within a 1 GB VPS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Memory Budget Breakdown<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Service<\/th><th>Image Size<\/th><th>Mem Limit<\/th><th>Mem Reservation<\/th><th>CPU Limit (optional)<\/th><\/tr><\/thead><tbody><tr><td>Nginx (Alpine)<\/td><td>23 MB<\/td><td>128 MB<\/td><td>64 MB<\/td><td>0.5<\/td><\/tr><tr><td>PHP-FPM 8.3 (Alpine)<\/td><td>85 MB<\/td><td>256 MB<\/td><td>128 MB<\/td><td>1.0<\/td><\/tr><tr><td>PostgreSQL 16 (Alpine)<\/td><td>157 MB<\/td><td>256 MB<\/td><td>128 MB<\/td><td>1.0<\/td><\/tr><tr><td>Redis 7 (Alpine)<\/td><td>32 MB<\/td><td>64 MB<\/td><td>32 MB<\/td><td>0.5<\/td><\/tr><tr><td><strong>Total<\/strong><\/td><td><strong>297 MB<\/strong><\/td><td><strong>704 MB<\/strong><\/td><td><strong>352 MB<\/strong><\/td><td><strong>3.0<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Compare this to a default Ubuntu-based stack: Nginx (187 MB), PHP (325 MB), PostgreSQL (378 MB), Redis (118 MB) = over 1 GB before any application data. Alpine images save 60\u201370% of baseline memory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Deploy and Verify<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>docker compose up -d\ndocker compose ps\ndocker stats --no-stream<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>docker stats<\/code> command shows real-time memory usage per container. With the limits above, the entire stack should idle around 400\u2013500 MB. If you&#8217;re close to your VPS&#8217;s RAM ceiling, increase swappiness to 10 (as covered in our swap optimization guide) and <a href=\"https:\/\/virtualserversvps.com\/#performance\">check our performance benchmarks<\/a> for VPS plans with faster storage to reduce swap latency.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Production Readiness<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Persistent storage:<\/strong> Named volumes (like <code>pgdata<\/code>) survive container rebuilds. Always use them for databases.<\/li><li><strong>Health checks:<\/strong> The <code>depends_on: condition: service_healthy<\/code> ensures services start in the correct order.<\/li><li><strong>Restart policy:<\/strong> Add <code>restart: unless-stopped<\/code> to each service for automatic recovery after crashes or VPS reboots.<\/li><li><strong>Resource limits:<\/strong> Without <code>mem_limit<\/code>, a memory leak in one container can starve all others. Always set limits.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For even tighter memory budgets, consider replacing PostgreSQL with SQLite (file-based, zero daemon overhead) or using a single Alpine container with multiple processes via supervisord. However, Docker Compose is the recommended approach for maintainability. <a href=\"https:\/\/virtualserversvps.com\/#features\">See our VPS comparison table<\/a> for plans optimized for containerized workloads.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Running multiple containers on a budget VPS (1\u20132 GB RAM) requires careful resource planning. Docker Compose makes orchestration straightforward, but default configurations can quickly exhaust memory. This guide shows how&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-484","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM\" \/>\n<meta property=\"og:description\" content=\"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-22T06:04:46+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/\",\"name\":\"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-06-22T06:04:46+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/","og_locale":"en_US","og_type":"article","og_title":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM","og_description":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM","og_url":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-06-22T06:04:46+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/","url":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/","name":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-06-22T06:04:46+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/docker-compose-vps-multi-container-minimal-ram\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Docker Compose for VPS: How to Orchestrate Multi-Container Applications with Minimal RAM"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=484"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/484\/revisions"}],"predecessor-version":[{"id":487,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/484\/revisions\/487"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}