{"id":1310,"date":"2026-11-20T23:34:30","date_gmt":"2026-11-20T18:04:30","guid":{"rendered":"https:\/\/merahost.org\/blog\/running-docker-and-docker-compose-on-a-cloud-vps-production-setup-storage-security\/"},"modified":"2026-11-20T23:34:30","modified_gmt":"2026-11-20T18:04:30","slug":"running-docker-and-docker-compose-on-a-cloud-vps-production-setup-storage-security","status":"publish","type":"post","link":"https:\/\/merahost.org\/blog\/running-docker-and-docker-compose-on-a-cloud-vps-production-setup-storage-security\/","title":{"rendered":"Running Docker and Docker Compose on a Cloud VPS: Production Setup, Storage &amp; Security"},"content":{"rendered":"<p>Deploying containerized microservices on cloud infrastructure often begins smoothly in local development, but transitioning to a production Cloud VPS frequently reveals critical performance bottlenecks in Linux kernel namespaces, storage I\/O amplification, and unmanaged container log accumulation. Without purposeful daemon tuning and host kernel configuration, default bridge networking degrades packet throughput while unconstrained container privileges expose internal host ports to external exploits. Enterprise web architectures hosted on <a href=\"https:\/\/merahost.org\">MeraHost<\/a> eliminate these production vulnerabilities by pairing high-performance NVMe storage with hardened Linux kernel parameters and predictable resource guarantees.<\/p>\n<p><!-- more --><\/p>\n<h2>Production Architecture Blueprint: Docker and Compose on Cloud VPS<\/h2>\n<div class=\"wp-block-group\" style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:24px 0\">\n<p style=\"margin:0;font-size:15px;line-height:1.6;color:#333\"><strong style=\"color:#001b41\">Direct Answer:<\/strong> A production Docker and Docker Compose deployment on a Cloud VPS requires a dedicated non-root execution model, optimized <code>overlay2<\/code> storage on enterprise NVMe, strict log rotation in <code>daemon.json<\/code>, custom internal bridge networks, and <code>sysctl<\/code> kernel parameter hardening. This architecture delivers deterministic sub-millisecond container latency and zero-downtime rolling updates without the complexity of Kubernetes.<\/p>\n<\/div>\n<p>While multi-node orchestration platforms like Kubernetes dominate enterprise conversations, single-node and multi-service workloads running on a dedicated Cloud VPS represent the vast majority of web application deployments. A properly configured VPS running modern Docker Engine and Docker Compose V2 delivers remarkable performance, ultra-low resource overhead, and straightforward maintenance. However, running containers in production demands architectural rigor far beyond running <code>docker compose up -d<\/code> with default settings.<\/p>\n<p>The standard Docker installation assumes an unconstrained development environment. By default, container logs write to unbounded JSON files on the root filesystem, container processes execute as root, network packets traverse non-optimized user-space proxy daemons, and storage layers suffer write amplification over conventional virtual disks. Transforming this development runtime into a resilient, production-ready infrastructure platform requires a holistic approach spanning host kernel tuning, storage subsystem configuration, daemon optimization, and declarative service manifests.<\/p>\n<h2>Cloud VPS vs. Default Docker Runtime: Architectural &amp; Cost Matrix<\/h2>\n<p>Understanding the performance and security disparity between an out-of-the-box Docker installation and a hardened, tuned production deployment on high-speed infrastructure is vital for infrastructure planning. The table below outlines key behavioral differences across vital operational dimensions:<\/p>\n<figure class=\"wp-block-table is-style-regular\">\n<table style=\"width:100%;border-collapse:collapse;margin:24px 0;font-size:15px;text-align:left\">\n<thead style=\"background:#001b41;color:#ffffff\">\n<tr>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Feature \/ Metric<\/th>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Standard \/ Default<\/th>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Tuned \/ Production<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Storage Driver &amp; I\/O<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Standard loopback \/ unconstrained overlay2<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Direct NVMe overlay2 with metadatacopy<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Logging Mechanism<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Uncapped json-file (disk exhaustion risk)<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Rotated JSON (max-size: 10m, max-file: 3)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Container Restart Policy<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">no (manual recovery required)<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">unless-stopped with healthcheck hooks<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Host Network Security<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Docker bypasses UFW rules automatically<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Explicit DOCKER-USER chain &amp; 127.0.0.1 bindings<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Daemon Restart Resilience<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Containers terminate on daemon restarts<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Live-Restore enabled (zero container downtime)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Privilege Model<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Root user default inside container namespace<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Non-root UID\/GID + cap_drop: [ALL]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2>Linux Kernel &amp; Host Operating System Hardening for Docker<\/h2>\n<p>Before launching your first container, the underlying Linux operating system must be tuned to handle high-frequency socket allocations, heavy connection tracking, and containerized memory limits. When multiple services communicate concurrently over virtual bridge networks, standard Linux kernel defaults quickly exhaust file descriptors and TCP connection backlogs, causing silent request drops.<\/p>\n<p>Deploy the following configuration to <code>\/etc\/sysctl.d\/99-docker-production.conf<\/code> to optimize network socket limits, enhance memory overcommit handling, and expand connection tracking capacity:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># \/etc\/sysctl.d\/99-docker-production.conf\n# Production Linux Kernel Tuning for Docker on Cloud VPS\n\n# Enable IPv4 forwarding for Docker bridge networks\nnet.ipv4.ip_forward = 1\nnet.ipv4.conf.all.forwarding = 1\n\n# Maximize socket connection backlog and SYN queues\nnet.core.somaxconn = 65535\nnet.ipv4.tcp_max_syn_backlog = 16384\nnet.core.netdev_max_backlog = 16384\n\n# Expand TCP buffer limits for high-bandwidth web traffic\nnet.ipv4.tcp_rmem = 4096 87380 16777216\nnet.ipv4.tcp_wmem = 4096 65536 16777216\n\n# Prevent socket exhaustion under burst traffic\nnet.ipv4.tcp_tw_reuse = 1\nnet.ipv4.tcp_fin_timeout = 15\n\n# Elevate system-wide file descriptor allocations\nfs.file-max = 2097152\nfs.inotify.max_user_instances = 8192\nfs.inotify.max_user_watches = 524288\n\n# Expand netfilter connection tracking table\nnet.netfilter.nf_conntrack_max = 262144\nnet.netfilter.nf_conntrack_tcp_timeout_established = 86400\n\n# Memory management &amp; Virtual Memory overcommit rules\nvm.max_map_count = 262144\nvm.swappiness = 10\nvm.overcommit_memory = 1<\/code><\/pre>\n<p>Apply these parameters immediately without rebooting the server by executing:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>sudo sysctl --system<\/code><\/pre>\n<blockquote class=\"wp-block-quote\" style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:24px 0\">\n<p><strong style=\"color:#001b41\">Architecture Note:<\/strong> When hosting high-throughput databases or search indices like PostgreSQL, MongoDB, or Elasticsearch in Docker containers, setting <code>vm.max_map_count = 262144<\/code> and <code>vm.overcommit_memory = 1<\/code> is mandatory. Failing to set these on the host will cause containerized memory allocators to crash during sudden transaction spikes.<\/p>\n<\/blockquote>\n<h2>Enterprise Docker Daemon Tuning: \/etc\/docker\/daemon.json<\/h2>\n<p>The Docker daemon configuration file controls critical operational behaviors, including disk-space protection, process isolation, and container uptime during host maintenance. One of the most prevalent causes of Cloud VPS outages is disk exhaustion driven by unrotated container <code>stdout<\/code> and <code>stderr<\/code> logs. In default setups, Docker writes logs indefinitely until the host filesystem reaches 100% capacity, halting the entire operating system.<\/p>\n<p>Create or update <code>\/etc\/docker\/daemon.json<\/code> with enterprise-grade defaults:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>{\n  \"storage-driver\": \"overlay2\",\n  \"storage-opts\": [\n    \"overlay2.override_kernel_check=true\"\n  ],\n  \"log-driver\": \"json-file\",\n  \"log-opts\": {\n    \"max-size\": \"10m\",\n    \"max-file\": \"3\",\n    \"compress\": \"true\"\n  },\n  \"live-restore\": true,\n  \"userland-proxy\": false,\n  \"no-new-privileges\": true,\n  \"default-ulimits\": {\n    \"nofile\": {\n      \"Name\": \"nofile\",\n      \"Hard\": 65535,\n      \"Soft\": 65535\n    },\n    \"nproc\": {\n      \"Name\": \"nproc\",\n      \"Hard\": 4096,\n      \"Soft\": 4096\n    }\n  },\n  \"metrics-addr\": \"127.0.0.1:9323\",\n  \"experimental\": false\n}<\/code><\/pre>\n<p>Key architectural directives explained:<\/p>\n<ul>\n<li><strong><code>live-restore: true<\/code><\/strong>: Ensures containers remain running even when the Docker daemon is updated, restarted, or experiences a transient crash. This prevents service outages during routine host OS updates.<\/li>\n<li><strong><code>log-opts (max-size &amp; max-file)<\/code><\/strong>: Enforces strict log rotation. Each container log is capped at 10 MB with 3 rotated archives, guaranteeing predictable, bounded disk utilization.<\/li>\n<li><strong><code>userland-proxy: false<\/code><\/strong>: Disables the legacy <code>docker-proxy<\/code> process, routing container network traffic directly via host <code>iptables<\/code>\/<code>nftables<\/code> NAT. This reduces CPU and memory overhead while lowering packet routing latency.<\/li>\n<li><strong><code>no-new-privileges: true<\/code><\/strong>: Prevents child processes inside containers from gaining additional privileges via <code>setuid<\/code> or <code>setgid<\/code> binaries, neutralizing common privilege escalation exploits.<\/li>\n<\/ul>\n<p>After saving the configuration, reload the systemd manager and restart Docker safely:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>sudo systemctl daemon-reload &amp;&amp; sudo systemctl restart docker<\/code><\/pre>\n<h2>Persistent Storage Architecture: Named Volumes vs. Host Bind Mounts<\/h2>\n<p>Containerized workloads require distinct persistent storage tiers. Choosing the wrong storage mechanism can severely degrade I\/O throughput or introduce file ownership collisions across host and container namespaces.<\/p>\n<p>In a production Cloud VPS environment, adhere to the following storage hierarchy:<\/p>\n<ul>\n<li><strong>Docker Named Volumes (Managed by Docker)<\/strong>: Best for transactional state (PostgreSQL, MySQL, Redis, MinIO). Named volumes reside under <code>\/var\/lib\/docker\/volumes\/<\/code>. When provisioned on enterprise NVMe storage like that on <a href=\"https:\/\/merahost.org\">MeraHost Enterprise Cloud<\/a>, named volumes bypass virtual filesystem translation layers, providing near-native raw disk write speeds.<\/li>\n<li><strong>Host Bind Mounts (Mapped Explicit Host Paths)<\/strong>: Best for static configuration files (e.g., <code>.\/nginx.conf:\/etc\/nginx\/nginx.conf:ro<\/code>) and static assets generated on the host. Always mount host configuration files with the <code>:ro<\/code> (read-only) flag to prevent compromised containers from altering host configurations.<\/li>\n<li><strong>Temporary Filesystems (tmpfs)<\/strong>: Best for ephemeral session tokens, scratch caches, or in-memory queues. Using <code>tmpfs<\/code> mounts ensures sensitive transient data is written strictly to RAM and wiped upon container restart.<\/li>\n<\/ul>\n<blockquote class=\"wp-block-quote\" style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:24px 0\">\n<p><strong style=\"color:#001b41\">Architecture Note:<\/strong> Never run active database storage over networked network-attached block storage or NFS mounts with high latency. Always pair transactional databases with high-speed local NVMe volumes to prevent lock contention, transaction delays, and write starvation during backup cycles.<\/p>\n<\/blockquote>\n<h2>Production Docker Compose V2 Architecture: Multi-Tier Web Stack<\/h2>\n<p>A resilient multi-container production deployment requires service isolation, strict resource constraints, declarative health probes, and internal networking. Below is a comprehensive, production-grade <code>docker-compose.yml<\/code> file orchestrating a reverse proxy (Caddy\/Traefik compatible), a hardened Node.js\/Go backend API, a Redis cache layer, and a PostgreSQL database.<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># docker-compose.yml - Production Multi-Tier Stack\nversion: \"3.8\"\n\nnetworks:\n  frontend_net:\n    driver: bridge\n    internal: false\n  backend_net:\n    driver: bridge\n    internal: true\n\nvolumes:\n  postgres_data:\n    driver: local\n  redis_data:\n    driver: local\n  caddy_data:\n    driver: local\n  caddy_config:\n    driver: local\n\nservices:\n  edge-proxy:\n    image: caddy:2.8-alpine\n    container_name: production_edge_proxy\n    restart: unless-stopped\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    volumes:\n      - .\/Caddyfile:\/etc\/caddy\/Caddyfile:ro\n      - caddy_data:\/data\n      - caddy_config:\/config\n    networks:\n      - frontend_net\n    deploy:\n      resources:\n        limits:\n          cpus: '1.0'\n          memory: 512M\n        reservations:\n          cpus: '0.25'\n          memory: 128M\n    security_opt:\n      - no-new-privileges:true\n    cap_drop:\n      - ALL\n    cap_add:\n      - NET_BIND_SERVICE\n\n  app-api:\n    image: ghcr.io\/company\/production-api:v2.4.1\n    container_name: production_app_api\n    restart: unless-stopped\n    user: \"1001:1001\"\n    read_only: true\n    tmpfs:\n      - \/tmp:rw,noexec,nosuid,size=64m\n    environment:\n      - NODE_ENV=production\n      - PORT=3000\n      - DB_HOST=database\n      - REDIS_HOST=cache\n    env_file:\n      - .env.production\n    networks:\n      - frontend_net\n      - backend_net\n    deploy:\n      resources:\n        limits:\n          cpus: '2.0'\n          memory: 1536M\n        reservations:\n          cpus: '0.50'\n          memory: 512M\n    healthcheck:\n      test: [\"CMD\", \"wget\", \"--no-verbose\", \"--tries=1\", \"--spider\", \"http:\/\/127.0.0.1:3000\/health\"]\n      interval: 15s\n      timeout: 5s\n      retries: 3\n      start_period: 20s\n    security_opt:\n      - no-new-privileges:true\n    cap_drop:\n      - ALL\n\n  cache:\n    image: redis:7.2-alpine\n    container_name: production_cache\n    restart: unless-stopped\n    command: [\"redis-server\", \"--requirepass\", \"${REDIS_PASSWORD}\", \"--appendonly\", \"yes\", \"--maxmemory\", \"384mb\", \"--maxmemory-policy\", \"allkeys-lru\"]\n    volumes:\n      - redis_data:\/data\n    networks:\n      - backend_net\n    deploy:\n      resources:\n        limits:\n          cpus: '0.75'\n          memory: 512M\n    security_opt:\n      - no-new-privileges:true\n    cap_drop:\n      - ALL\n\n  database:\n    image: postgres:16-alpine\n    container_name: production_database\n    restart: unless-stopped\n    environment:\n      POSTGRES_DB: ${DB_NAME}\n      POSTGRES_USER: ${DB_USER}\n      POSTGRES_PASSWORD: ${DB_PASSWORD}\n    volumes:\n      - postgres_data:\/var\/lib\/postgresql\/data\n    networks:\n      - backend_net\n    deploy:\n      resources:\n        limits:\n          cpus: '2.0'\n          memory: 2048M\n        reservations:\n          cpus: '0.5'\n          memory: 512M\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U ${DB_USER} -d ${DB_NAME}\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n    security_opt:\n      - no-new-privileges:true<\/code><\/pre>\n<p>Critical architectural highlights in this Compose configuration:<\/p>\n<ul>\n<li><strong>Network Partitioning<\/strong>: The <code>backend_net<\/code> is designated with <code>internal: true<\/code>. Neither Redis nor PostgreSQL can communicate with the external Internet or the host gateway, rendering direct external attacks impossible even if an attacker probes the VPS.<\/li>\n<li><strong>Zero Unmapped Ports<\/strong>: Notice that neither Redis nor PostgreSQL publish ports to the host (no <code>ports:<\/code> block). They are strictly reachable via container name resolution on <code>backend_net<\/code>.<\/li>\n<li><strong>Resource Constraints<\/strong>: Both <code>limits<\/code> and <code>reservations<\/code> prevent noisy-neighbor container starvation and shield the Linux host from Out-Of-Memory (OOM) killer panics.<\/li>\n<li><strong>Immutable Root Filesystem<\/strong>: The <code>app-api<\/code> container runs with <code>read_only: true<\/code>, disallowing malicious tampering or file modification inside running containers. Transient writes are restricted to an in-memory <code>tmpfs<\/code> mount.<\/li>\n<\/ul>\n<h2>The Docker and UFW Firewall Dilemma: Restoring Network Security<\/h2>\n<p>One of the most dangerous architectural pitfalls in Linux systems administration is the interaction between Docker and the Uncomplicated Firewall (UFW). By default, Docker injects rules directly into the host <code>iptables<\/code> prerouting chain before UFW rules execute. Consequently, if you publish a port using <code>ports: - \"5432:5432\"<\/code> in Docker Compose, that port becomes publicly accessible to the entire Internet, completely ignoring <code>ufw default deny incoming<\/code>.<\/p>\n<p>To prevent unauthorized public exposure, use one of two robust patterns:<\/p>\n<h3>Method A: Localhost Binding (Recommended for Single-Host Proxies)<\/h3>\n<p>Explicitly bind all internal ports to the loopback interface in your Compose file:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>ports:\n  - \"127.0.0.1:8080:8080\"  # Only accessible to local host reverse proxy<\/code><\/pre>\n<h3>Method B: The DOCKER-USER iptables Filter Chain<\/h3>\n<p>For fine-grained host firewalling, configure Docker&#8217;s dedicated filter chain in <code>\/etc\/ufw\/after.rules<\/code>. Docker preserves rules placed in <code>DOCKER-USER<\/code>. Add the following block to the bottom of <code>\/etc\/ufw\/after.rules<\/code>:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># \/etc\/ufw\/after.rules\n# Protect Docker published ports via DOCKER-USER chain\n*filter\n:DOCKER-USER - [0:0]\n-A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT\n-A DOCKER-USER -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT\n-A DOCKER-USER -i eth0 -p tcp -m tcp --dport 443 -j ACCEPT\n-A DOCKER-USER -i eth0 -j DROP\nCOMMIT<\/code><\/pre>\n<p>Reload UFW to enforce the protection:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>sudo ufw reload<\/code><\/pre>\n<h2>Automated Maintenance &amp; Container Lifecycle Operations<\/h2>\n<p>Over time, unused image layers, stopped builder stages, and dangling volumes accumulate on the host disk. Implement an automated maintenance schedule using a systemd timer or cron job to maintain consistent disk hygiene without interrupting active services.<\/p>\n<p>Create a weekly maintenance script at <code>\/usr\/local\/bin\/docker-maintenance.sh<\/code>:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>#!\/usr\/bin\/env bash\n# \/usr\/local\/bin\/docker-maintenance.sh\nset -euo pipefail\n\n# Purge stopped containers older than 72 hours\ndocker container prune -f --filter \"until=72h\"\n\n# Remove untagged and dangling image layers\ndocker image prune -f\n\n# Clean unused builder cache layers\ndocker builder prune -f --keep-storage 2GB\n\n# Verify active volume integrity\ndocker system df<\/code><\/pre>\n<p>Make the script executable and schedule it to run weekly:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>sudo chmod +x \/usr\/local\/bin\/docker-maintenance.sh\n(crontab -l 2&gt;\/dev\/null; echo \"0 3 * * 0 \/usr\/local\/bin\/docker-maintenance.sh &gt; \/var\/log\/docker-prune.log 2&gt;&amp;1\") | crontab -<\/code><\/pre>\n<h2>Frequently Asked Questions<\/h2>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">Why does Docker bypass my Linux UFW firewall rules by default?<\/summary>\n<p style=\"margin-top:10px;color:#444\">Docker modifies the host iptables directly to enable container network address translation (NAT). Because Docker&#8217;s PREROUTING rules execute before UFW&#8217;s input filtering chain, any port mapped with a public port binding (such as <code>-p 8080:8080<\/code>) bypasses UFW blocks. To fix this, bind ports explicitly to <code>127.0.0.1<\/code> or configure the <code>DOCKER-USER<\/code> chain in <code>\/etc\/ufw\/after.rules<\/code>.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">What is the advantage of live-restore in production Docker setups?<\/summary>\n<p style=\"margin-top:10px;color:#444\">Enabling <code>\"live-restore\": true<\/code> in <code>\/etc\/docker\/daemon.json<\/code> allows running containers to remain active and serving traffic even when the Docker daemon process restarts, crashes, or is upgraded during operating system updates. Without live-restore, restarting the Docker daemon abruptly stops every running container on the host.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">Should I use named volumes or host bind mounts for databases?<\/summary>\n<p style=\"margin-top:10px;color:#444\">For transactional databases like PostgreSQL and MySQL, named volumes managed under <code>\/var\/lib\/docker\/volumes<\/code> are strongly recommended. They provide superior I\/O throughput on enterprise NVMe disks, prevent UID\/GID permissions conflicts between the container and host, and integrate cleanly with Docker&#8217;s volume backup and snapshot workflows.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">How do I achieve zero-downtime container deployments using Docker Compose?<\/summary>\n<p style=\"margin-top:10px;color:#444\">You can achieve zero downtime by deploying behind a dynamic reverse proxy (such as Caddy, Traefik, or Nginx) combined with container health checks. Run <code>docker compose up -d --no-deps --scale app-api=2 --no-recreate app-api<\/code>, wait for health probes to confirm the new container is healthy, and subsequently retire the outdated container.<\/p>\n<\/details>\n<div class=\"wp-block-group has-background\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:8px;padding:32px;margin:40px 0;text-align:center\">\n<h3 style=\"color:#001b41;margin-top:0;font-size:24px;font-weight:700\">Deploy Enterprise-Grade Production Infrastructure<\/h3>\n<p style=\"color:#444;font-size:16px;line-height:1.6;max-width:680px;margin:12px auto 24px auto\">Need guaranteed performance with zero price hikes? Host mission-critical workloads on <strong style=\"color:#001b41\">MeraHost<\/strong> with pure Enterprise NVMe, LiteSpeed Web Server, and Same Renewal Price, Always (starting at \u20b999\/mo).<\/p>\n<div class=\"wp-block-buttons\" style=\"display:flex;gap:16px;justify-content:center;flex-wrap:wrap\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" href=\"https:\/\/merahost.org\" style=\"background:#001b41;color:#ffffff;font-weight:700;padding:12px 28px;border-radius:4px;text-decoration:none;display:inline-block;font-size:15px\">Explore MeraHost NVMe Cloud &rarr;<\/a><\/div>\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link\" href=\"https:\/\/cpanelfree.com\" style=\"background:transparent;color:#001b41;font-weight:600;padding:12px 24px;border:2px solid #001b41;border-radius:4px;text-decoration:none;display:inline-block;font-size:15px\" rel=\"nofollow noopener\" target=\"_blank\">Deploy Free Staging on CpanelFree<\/a><\/div>\n<\/div>\n<\/div>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1310&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;20&quot;,&quot;title&quot;:&quot;Running Docker and Docker Compose on a Cloud VPS: Production Setup, Storage \\u0026amp; Security&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 20px; height: 20px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 16px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Master production Docker and Docker Compose on a cloud VPS. Configure persistent NVMe storage, daemon hardening, sysctl tuning, and zero-downtime deployments.<\/p>\n","protected":false},"author":1,"featured_media":1309,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[163],"tags":[164,126,125,129,127],"class_list":["post-1310","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-infrastructure","tag-cloud-infrastructure","tag-devops","tag-linux","tag-performance","tag-sysadmin"],"_links":{"self":[{"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/posts\/1310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/comments?post=1310"}],"version-history":[{"count":0,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/posts\/1310\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/media\/1309"}],"wp:attachment":[{"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/media?parent=1310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/categories?post=1310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merahost.org\/blog\/wp-json\/wp\/v2\/tags?post=1310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}