{"id":13188,"date":"2025-08-29T17:00:03","date_gmt":"2025-08-29T11:15:03","guid":{"rendered":"https:\/\/nestnepal.com\/blog\/?p=13188"},"modified":"2025-10-28T11:42:53","modified_gmt":"2025-10-28T05:57:53","slug":"wordpress-docker-compose-step-wise-guide-2025","status":"publish","type":"post","link":"https:\/\/nestnepal.com\/blog\/wordpress-docker-compose-step-wise-guide-2025\/","title":{"rendered":"Step-by-Step: Deploying WordPress with Docker Compose (Beginner-Friendly Guide)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Remember the days when setting up WordPress meant wrestling with XAMPP, configuring databases, and dealing with version conflicts that made you want to throw your laptop out the window? Well, those days are officially over. Welcome to the world of Docker, where setting up WordPress is as easy as ordering momo on Foodmandu.<\/p>\n\n\n\n<p>If you&#8217;ve been hearing about <a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" rel=\"noopener\">Docker<\/a> and thinking it&#8217;s only for hardcore developers, think again. Docker has become the go-to solution for web developers and businesses worldwide, and it&#8217;s time Nepal&#8217;s web community embraced this game-changing technology. At <a href=\"https:\/\/nestnepal.com\/\">Nest Nepal<\/a>, we&#8217;ve seen businesses cut their deployment time from hours to minutes using Docker.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"394\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-32-1024x394.png\" alt=\"docker compose\" class=\"wp-image-13189 lazyload\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-32-1024x394.png 1024w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-32-300x115.png 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-32-768x295.png 768w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-32.png 1300w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/394;\" \/><\/figure>\n\n\n\n<p>Today, we&#8217;re going to walk through deploying WordPress with Docker Compose in a way that&#8217;s so simple, even your cousin who still thinks &#8220;the cloud&#8221; is something in the sky will understand it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Exactly Is Docker and Why Should You Care?<\/strong><\/h2>\n\n\n\n<p>Before we dive into the technical stuff, let&#8217;s understand what we&#8217;re dealing with. Think of Docker as a magic box that packages your entire WordPress site- the code, database, web server, and all dependencies into a single, portable container.<\/p>\n\n\n\n<p>It&#8217;s like having a complete restaurant (your WordPress site) that you can pack up and set up anywhere in minutes, complete with the kitchen, dining area, and all the equipment, without worrying about whether the new location has the right infrastructure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Traditional WordPress Headache<\/strong><\/h3>\n\n\n\n<p>Here&#8217;s what setting up WordPress traditionally looked like:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install a web server (Apache\/Nginx)<\/li>\n\n\n\n<li>Install PHP and configure it<\/li>\n\n\n\n<li>Install MySQL database<\/li>\n\n\n\n<li>Download WordPress<\/li>\n\n\n\n<li><a href=\"https:\/\/nestnepal.com\/blog\/wordpress-performance-tune-caching-lazy-loading\/\">WordPress Tuning<\/a><\/li>\n\n\n\n<li>Deal with version conflicts<\/li>\n\n\n\n<li>Pray nothing breaks<\/li>\n\n\n\n<li>When something inevitably breaks, spend hours troubleshooting<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Docker Way<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"860\" height=\"430\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-33.png\" alt=\"docker-compose\" class=\"wp-image-13193 lazyload\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-33.png 860w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-33-300x150.png 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/08\/image-33-768x384.png 768w\" data-sizes=\"(max-width: 860px) 100vw, 860px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 860px; --smush-placeholder-aspect-ratio: 860\/430;\" \/><\/figure>\n\n\n\n<p>With Docker Compose, it looks like this:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a configuration file<\/li>\n\n\n\n<li>Run one command<\/li>\n\n\n\n<li>Your WordPress site is ready<\/li>\n\n\n\n<li>Seriously, that&#8217;s it<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Docker Compose vs. Traditional Hosting: The Reality Check<\/strong><\/h2>\n\n\n\n<p>Let me share a real example. Last month, a client in Lalitpur wanted to set up a development environment that matched their production server exactly. With traditional methods, it took our team 6 hours and multiple back-and-forth emails to get everything working correctly.<\/p>\n\n\n\n<p>With Docker? 15 minutes. Same environment, every time, on any computer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Why Docker Compose Is Perfect for WordPress in Nepal<\/strong><\/h3>\n\n\n\n<p><strong>1. Consistency Across Environments<\/strong>: Your local development environment will be identical to your staging and production environments. No more &#8220;it works on my machine&#8221; problems.<\/p>\n\n\n\n<p><strong>2. Easy Backups and Migration<\/strong>: Moving your entire WordPress setup to a new server? Just copy a few files and run a command. It&#8217;s that simple.<\/p>\n\n\n\n<p><strong>3. Resource Efficiency<\/strong>: Docker containers use fewer resources than traditional virtual machines, which is perfect when you&#8217;re working with limited server resources.<\/p>\n\n\n\n<p><strong>4. <a href=\"https:\/\/nestnepal.com\/blog\/migrate-php-mysql-website-into-docker-container\/\">Version Control<\/a>:<\/strong> Want to test WordPress 6.4 but keep 6.3 as backup? Easy. Want PHP 8.1 for one project and PHP 7.4 for another? No problem.<\/p>\n\n\n\n<p><strong>5. Team Collaboration:<\/strong> Your entire team can have identical development environments, regardless of whether they&#8217;re using Windows, Mac, or Linux.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites: What You Need Before We Start<\/strong><\/h2>\n\n\n\n<p>Don&#8217;t worry \u2013 the requirements are minimal:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>System Requirements<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Any computer<\/strong> with at least 4GB RAM (8GB recommended)<\/li>\n\n\n\n<li><strong>10GB free disk space<\/strong><\/li>\n\n\n\n<li><strong>Internet connection<\/strong> for initial downloads<\/li>\n\n\n\n<li><strong>Basic familiarity with the command line<\/strong> (don&#8217;t panic \u2013 we&#8217;ll guide you through everything)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Software Requirements<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Docker Desktop<\/strong> (free)<\/li>\n\n\n\n<li><strong>A text editor<\/strong> (VS Code, Notepad++, or even Windows Notepad works)<\/li>\n\n\n\n<li><strong>Web browser<\/strong> (you already have this)<\/li>\n<\/ol>\n\n\n\n<p>That&#8217;s it. No XAMPP, no separate MySQL installation, no PHP configuration headaches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Installing Docker: Your First Step<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>For Windows Users<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download Docker Compose Desktop<br><\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to https:\/\/www.docker.com\/products\/docker-desktop<\/li>\n\n\n\n<li>Download the Windows version<\/li>\n\n\n\n<li>Run the installer (it&#8217;s about 400MB)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Installation Process<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li>Follow the installation wizard<\/li>\n\n\n\n<li>When prompted, enable WSL 2 (Windows Subsystem for Linux)<\/li>\n\n\n\n<li>Restart your computer when asked<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Verify Installation<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li>Open Command Prompt or PowerShell<\/li>\n\n\n\n<li>Type: docker &#8211;version<\/li>\n\n\n\n<li>You should see something like &#8220;Docker version 24.0.6&#8221;<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>For Mac Users<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download Docker Desktop<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to https:\/\/www.docker.com\/products\/docker-desktop<\/li>\n\n\n\n<li>Choose the version for your Mac (Intel or Apple Silicon)<\/li>\n\n\n\n<li>Install like any other Mac application<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Verify Installation<\/strong><strong><br><\/strong>\n<ul class=\"wp-block-list\">\n<li>Open Terminal<\/li>\n\n\n\n<li>Type: docker &#8211;version<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>For Linux Users (Ubuntu\/Debian)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Update your system\nsudo apt update\n\n# Install Docker\nsudo apt install docker.io docker-compose\n\n# Start Docker service\nsudo systemctl start docker\nsudo systemctl enable docker\n\n# Add your user to docker group (to avoid using sudo)\nsudo usermod -aG docker $USER\n\n# Log out and log back in, then verify\ndocker --version<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Understanding Docker Compose<\/strong><\/h2>\n\n\n\n<p>Docker Compose is like a recipe book for Docker. Instead of manually starting multiple containers (one for WordPress, one for the database, etc.), you write a &#8220;recipe&#8221; (called a docker-compose.yml file) that describes your entire application stack.<\/p>\n\n\n\n<p>Think of it as creating a meal kit; everything you need is packaged together with clear instructions, and you can recreate the same meal anywhere.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Creating Your WordPress Project Structure<\/strong><\/h2>\n\n\n\n<p>Let&#8217;s create a proper folder structure for our WordPress project. This organization will make managing your site much easier.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Create Project Directory<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Navigate to your desired location (e.g., Desktop)\ncd ~\/Desktop\n\n# Create project folder\nmkdir my-wordpress-site\ncd my-wordpress-site\n\n# Create subdirectories\nmkdir wordpress-data\nmkdir database-data\n\nYour folder structure should look like this:\nmy-wordpress-site\/\n\u251c\u2500\u2500 docker-compose.yml (we'll create this next)\n\u251c\u2500\u2500 wordpress-data\/ (WordPress files will live here)\n\u2514\u2500\u2500 database-data\/ (MySQL data will be stored here)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Create the Docker Compose Configuration<\/strong><\/h3>\n\n\n\n<p>This is where the magic happens. Create a file named docker-compose.yml in your project directory and add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.8'\n\nservices:\n  # WordPress service\n  wordpress:\n    image: wordpress:latest\n    container_name: my-wordpress\n    restart: unless-stopped\n    ports:\n      - \"8080:80\"\n    environment:\n      WORDPRESS_DB_HOST: database:3306\n      WORDPRESS_DB_USER: wordpress_user\n      WORDPRESS_DB_PASSWORD: strong_password_123\n      WORDPRESS_DB_NAME: wordpress_db\n    volumes:\n      - .\/wordpress-data:\/var\/www\/html\n    depends_on:\n      - database\n    networks:\n      - wordpress-network\n\n  # MySQL database service\n  database:\n    image: mysql:8.0\n    container_name: my-wordpress-db\n    restart: unless-stopped\n    environment:\n      MYSQL_DATABASE: wordpress_db\n      MYSQL_USER: wordpress_user\n      MYSQL_PASSWORD: strong_password_123\n      MYSQL_ROOT_PASSWORD: root_password_123\n    volumes:\n      - .\/database-data:\/var\/lib\/mysql\n    networks:\n      - wordpress-network\n\n  # phpMyAdmin for database management (optional but helpful)\n  phpmyadmin:\n    image: phpmyadmin:latest\n    container_name: my-phpmyadmin\n    restart: unless-stopped\n    ports:\n      - \"8081:80\"\n    environment:\n      PMA_HOST: database\n      PMA_PORT: 3306\n      MYSQL_ROOT_PASSWORD: root_password_123\n    depends_on:\n      - database\n    networks:\n      - wordpress-network\n\nnetworks:\n  wordpress-network:\n    driver: bridge\n\nvolumes:\n  wordpress-data:\n  database-data:<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Understanding the Configuration<\/strong><\/h3>\n\n\n\n<p>Let me break down what this configuration does:<\/p>\n\n\n\n<p><strong>WordPress Service:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Uses the official WordPress Docker image<\/li>\n\n\n\n<li>Runs on port 8080 (so you&#8217;ll access it via http:\/\/localhost:8080)<\/li>\n\n\n\n<li>Connects to our database service<\/li>\n\n\n\n<li>Stores WordPress files in the wordpress-data folder<\/li>\n<\/ul>\n\n\n\n<p><strong>Database Service:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Uses MySQL 8.0<\/li>\n\n\n\n<li>Creates a database specifically for WordPress<\/li>\n\n\n\n<li>Stores data in the database-data folder<\/li>\n\n\n\n<li>Uses secure passwords (change these for production!)<\/li>\n<\/ul>\n\n\n\n<p><strong>phpMyAdmin Service:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Provides a web interface for database management<\/li>\n\n\n\n<li>Accessible at http:\/\/localhost:8081<\/li>\n\n\n\n<li>Optional but incredibly helpful for beginners<\/li>\n<\/ul>\n\n\n\n<p><strong>Networks:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creates a private network so all services can communicate securely<\/li>\n<\/ul>\n\n\n\n<p><strong>Volumes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensures your data persists even if containers are recreated<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Deploying Your WordPress Site<\/strong><\/h2>\n\n\n\n<p>Now comes the exciting part: actually launching your WordPress site!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Launch the Services<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Open your terminal\/command prompt, navigate to your project directory, and run:\n# Navigate to your project directory\ncd ~\/Desktop\/my-wordpress-site\n\n# Start all services\ndocker-compose up -d\n\nThe -d flag runs everything in \"detached\" mode (in the background).\nYou'll see output like this:\nCreating network \"my-wordpress-site_wordpress-network\" with driver \"bridge\"\nCreating my-wordpress-db ... done\nCreating my-phpmyadmin  ... done\nCreating my-wordpress   ... done<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Verify Everything Is Running<\/strong><\/h3>\n\n\n\n<p>Check that all containers are running properly:<\/p>\n\n\n\n<p><em>docker-compose ps<\/em><\/p>\n\n\n\n<p>You should see all three services with &#8220;Up&#8221; status.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Access Your WordPress Site<\/strong><\/h3>\n\n\n\n<p>Open your web browser and go to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em><strong>WordPress site<\/strong>: http:\/\/localhost:8080<\/em><\/li>\n\n\n\n<li><em><strong>phpMyAdmin<\/strong>: http:\/\/localhost:8081<\/em><\/li>\n<\/ul>\n\n\n\n<p>You should see the famous WordPress 5-minute installation screen!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WordPress Installation Process<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Choose Your Language<\/strong><\/h3>\n\n\n\n<p>Select your preferred language (\u0928\u0947\u092a\u093e\u0932\u0940 is available if you want to create a Nepali WordPress site).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Database Connection<\/strong><\/h3>\n\n\n\n<p>WordPress will automatically detect the database connection; this is the magic of Docker Compose networking!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Site Configuration<\/strong><\/h3>\n\n\n\n<p>Fill in your site details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Site Title<\/strong>: Your website name<\/li>\n\n\n\n<li><strong>Username<\/strong>: Admin username (don&#8217;t use &#8216;admin&#8217; for security)<\/li>\n\n\n\n<li><strong>Password<\/strong>: Strong password<\/li>\n\n\n\n<li><strong>Email<\/strong>: Your email address<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Install WordPress<\/strong><\/h3>\n\n\n\n<p>Click &#8220;Install WordPress&#8221; and wait for the magic to happen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Managing Your WordPress Docker Environment<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Starting and Stopping Services<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Start all services\ndocker-compose up -d\n\n# Stop all services\ndocker-compose down\n\n# Restart services\ndocker-compose restart\n\n# View logs\ndocker-compose logs wordpress<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Updating WordPress and MySQL<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Stop services\ndocker-compose down\n\n# Pull latest images\ndocker-compose pull\n\n# Start with updated images\ndocker-compose up -d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Customizing Your Setup<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Adding SSL (HTTPS) Support<\/strong><\/h3>\n\n\n\n<p>For production use, you&#8217;ll want HTTPS. Here&#8217;s how to add it:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Nginx Proxy Manager<\/strong> (easiest option)<\/li>\n\n\n\n<li><strong>Use Traefik<\/strong> (more advanced but powerful)<\/li>\n\n\n\n<li><strong>Use Cloudflare<\/strong> (recommended for beginners)<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Performance Optimization<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Add these environment variables to your WordPress service:\nenvironment:\n  # ... existing environment variables ...\n  WORDPRESS_CONFIG_EXTRA: |\n    define('WP_MEMORY_LIMIT', '256M');\n    define('WP_MAX_MEMORY_LIMIT', '512M');\n    define('WP_CACHE', true);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Adding Redis for Caching<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Add this service to your docker-compose.yml:\n redis:\n    image: redis:alpine\n    container_name: my-redis\n    restart: unless-stopped\n    networks:\n      - wordpress-network<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Backup and Migration Strategies<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Creating Backups<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Create a complete backup\ndocker-compose exec database mysqldump -u root -p wordpress_db &gt; backup.sql\n\n# Backup WordPress files\ncp -r wordpress-data wordpress-backup-$(date +%Y%m%d)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Migrating to Production<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Copy your entire project folder<\/strong> to the production server<\/li>\n\n\n\n<li><strong>Update database passwords<\/strong> in docker-compose.yml<\/li>\n\n\n\n<li><strong>Change port mappings<\/strong> (use 80:80 instead of 8080:80)<\/li>\n\n\n\n<li><strong>Run docker-compose up -d<\/strong><\/li>\n<\/ol>\n\n\n\n<p>That&#8217;s it! Your entire WordPress site moves with just a folder copy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Troubleshooting Common Issues<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Issue 1: Port Already in Use<\/strong><\/h3>\n\n\n\n<p><strong>Error<\/strong>: &#8220;Port 8080 is already in use&#8221; <\/p>\n\n\n\n<p><strong>Solution<\/strong>: Change the port in docker-compose.yml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ports:\n  - \"8090:80\"  # Use port 8090 instead<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Issue 2: Database Connection Error<\/strong><\/h3>\n\n\n\n<p><strong>Error<\/strong>: &#8220;Error establishing a database connection.&#8221; <\/p>\n\n\n\n<p><strong>Solutions<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Wait 30-60 seconds for MySQL to fully start<\/li>\n\n\n\n<li>Check that all containers are running: <em>docker-compose ps<\/em><\/li>\n\n\n\n<li>Restart services: <em>docker-compose restart<\/em><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Issue 3: Permission Denied<\/strong><\/h3>\n\n\n\n<p><strong>Error<\/strong>: Permission issues with volumes. <\/p>\n\n\n\n<p><strong>Solution<\/strong> (Linux\/Mac):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R $USER:$USER wordpress-data\nsudo chown -R $USER:$USER database-data<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Issue 4: Out of Disk Space<\/strong><\/h3>\n\n\n\n<p><strong>Error<\/strong>: No space left on device. <\/p>\n\n\n\n<p><strong>Solution<\/strong>: Clean up Docker:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker system prune -a<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Production Deployment Considerations<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Security Hardening<\/strong><\/h3>\n\n\n\n<p><strong>Change Default Passwords<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>environment:\nMYSQL_PASSWORD: your-super-strong-password-here\nMYSQL_ROOT_PASSWORD: another-super-strong-password<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Remove phpMyAdmin<\/strong> (not needed in production)<br>\n<ul class=\"wp-block-list\">\n<li>Comment out or remove the phpMyAdmin service<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><strong>Use Environment Files:<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Create a .env file for sensitive data:\n\nDB_PASSWORD=your-secret-password\nDB_ROOT_PASSWORD=your-secret-root-password<\/code><\/pre>\n\n\n\n<p><strong>Limit Resource Usage<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> deploy:\n  resources:\n    limits:\n      memory: 512M\n      cpus: \"0.5\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Performance Optimization<\/strong><\/h3>\n\n\n\n<p><strong>Use Specific Image Versions<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>image: wordpress:6.4-php8.1-apache\nimage: mysql:8.0.35<\/code><\/pre>\n\n\n\n<p><strong>Configure MySQL for Better Performance<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>command: --innodb-buffer-pool-size=128M --max-connections=50<\/code><\/pre>\n\n\n\n<p><strong>Add Health Checks<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> healthcheck:\n  test: &#91;\"CMD\", \"curl\", \"-f\", \"http:\/\/localhost\"]\n  interval: 30s\n  timeout: 10s\n  retries: 5<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Scaling Your WordPress Site<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Multiple WordPress Sites<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>You can run multiple WordPress sites with different configurations:\n# Site 1\nmkdir site1 &amp;&amp; cd site1\n# Create docker-compose.yml with ports 8080, 8081\n\n# Site 2  \nmkdir ..\/site2 &amp;&amp; cd ..\/site2\n# Create docker-compose.yml with ports 8090, 8091<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Load Balancing<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>For high-traffic sites, add a load balancer:\n nginx:\n    image: nginx:alpine\n    ports:\n      - \"80:80\"\n    volumes:\n      - .\/nginx.conf:\/etc\/nginx\/nginx.conf\n    depends_on:\n      - wordpress1\n      - wordpress2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Monitoring and Logging<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Container Health Monitoring<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Check container status\ndocker-compose ps\n\n# View resource usage\ndocker stats\n\n# Check logs\ndocker-compose logs -f wordpress<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Setting Up Log Rotation<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Add to your docker-compose.yml:\nlogging:\n  driver: \"json-file\"\n  options:\n    max-size: \"10m\"\n    max-file: \"3\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Advanced Docker Compose Features<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using Override Files<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Create docker-compose.override.yml for development-specific settings:\nversion: '3.8'\nservices:\n  wordpress:\n    environment:\n      WORDPRESS_DEBUG: 1\n    volumes:\n      - .\/themes:\/var\/www\/html\/wp-content\/themes\n      - .\/plugins:\/var\/www\/html\/wp-content\/plugins<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Environment-Specific Configurations<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Development\ndocker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d\n\n# Production\ndocker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Integration with CI\/CD<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>GitHub Actions Example<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>name: Deploy WordPress\non:\n  push:\n    branches: &#91;main]\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\/checkout@v2\n      - name: Deploy to server\n        run: |\n          docker-compose pull\n          docker-compose up -d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why This Matters for Nepal&#8217;s Web Development Scene<\/strong><\/h2>\n\n\n\n<p>The adoption of Docker and containerization technologies is revolutionizing how we develop and deploy websites globally. For Nepal&#8217;s growing tech industry, mastering these tools means:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Competitive Advantage<\/strong>: Clients worldwide expect modern deployment practices<\/li>\n\n\n\n<li><strong>Faster Development<\/strong>: Reduced setup time means more time for actual development<\/li>\n\n\n\n<li><strong>Better Collaboration<\/strong>: Teams can work seamlessly across different environments<\/li>\n\n\n\n<li><strong>Cost Efficiency<\/strong>: Fewer server resources needed, lower hosting costs<\/li>\n\n\n\n<li><strong>Professional Growth<\/strong>: Docker skills are highly valued in the international job market<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Mistakes to Avoid<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Not Using Volume Mounts<\/strong><\/h3>\n\n\n\n<p><strong>Wrong<\/strong>: Letting Docker manage data internally <\/p>\n\n\n\n<p><strong>Right<\/strong>: Using volume mounts to persist data<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Using Default Passwords in Production<\/strong><\/h3>\n\n\n\n<p><strong>Wrong<\/strong>: Keeping &#8216;password123&#8217; in production <\/p>\n\n\n\n<p><strong>Right<\/strong>: Using strong, unique passwords<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Not Managing Container Resources<\/strong><\/h3>\n\n\n\n<p><strong>Wrong<\/strong>: Letting containers use unlimited resources <\/p>\n\n\n\n<p><strong>Right<\/strong>: Setting memory and CPU limits<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Ignoring Security Updates<\/strong><\/h3>\n\n\n\n<p><strong>Wrong<\/strong>: Never updating Docker images <\/p>\n\n\n\n<p><strong>Right<\/strong>: Regular updates using docker-compose pull<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Not Backing Up Data<\/strong><\/h3>\n\n\n\n<p><strong>Wrong<\/strong>: Assuming Docker handles backups <\/p>\n\n\n\n<p><strong>Right<\/strong>: Creating regular backups of volumes<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Next Steps: Taking Your Docker Skills Further<\/strong><\/h2>\n\n\n\n<p>Once you&#8217;re comfortable with this basic WordPress setup, consider exploring:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Multi-stage builds<\/strong> for custom WordPress images<\/li>\n\n\n\n<li><strong>Docker Swarm<\/strong> for container orchestration<\/li>\n\n\n\n<li><strong>Kubernetes<\/strong> for enterprise-level deployments<\/li>\n\n\n\n<li><strong>CI\/CD pipelines<\/strong> with automated testing and deployment<\/li>\n\n\n\n<li><strong>Monitoring solutions<\/strong> like Prometheus and Grafana<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion: Welcome to Modern WordPress Development<\/strong><\/h2>\n\n\n\n<p>Congratulations! You&#8217;ve just deployed WordPress using Docker Compose. A skill that puts you ahead of 90% of traditional WordPress developers. What used to be hours of configuration and troubleshooting is now a simple, repeatable process.<\/p>\n\n\n\n<p>This isn&#8217;t just about making your life easier (though it definitely does that). It&#8217;s about adopting industry-standard practices that will serve you well, whether you&#8217;re building sites for local businesses in Kathmandu or clients in Silicon Valley.<\/p>\n\n\n\n<p>The beauty of Docker is that it grows with you. Start with simple WordPress sites, then expand to complex applications with multiple services, databases, and integrations. The principles remain the same, but the possibilities are endless.<\/p>\n\n\n\n<p>At Nest Nepal, we&#8217;ve seen how adopting modern deployment practices like Docker has helped our clients launch faster, scale easier, and maintain their sites with confidence. It&#8217;s not just a technical upgrade, it&#8217;s a business advantage.<\/p>\n\n\n\n<p>Your WordPress journey with Docker starts here, but it doesn&#8217;t end here. Keep experimenting, keep learning, and most importantly, keep building amazing things. The Nepal tech community is growing stronger every day, and you&#8217;re now part of that growth.<\/p>\n\n\n\n<p>Remember, every expert was once a beginner. You&#8217;ve taken the first step into modern web development practices, and that&#8217;s something to be proud of.<\/p>\n\n\n\n<p><em>Ready to take your <a href=\"https:\/\/nestnepal.com\/wordpress-hosting-in-nepal\/\">WordPress hosting<\/a> to the next level with Docker? Need help setting up production environments or scaling your containerized applications? The team at Nest Nepal specializes in modern hosting solutions and would love to help you leverage the full power of Docker for your business needs.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Remember the days when setting up WordPress meant wrestling with XAMPP, configuring databases, and dealing with version conflicts that&#8230;<\/p>\n","protected":false},"author":15,"featured_media":13272,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[373],"class_list":["post-13188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-hosting","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/13188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/comments?post=13188"}],"version-history":[{"count":5,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/13188\/revisions"}],"predecessor-version":[{"id":13500,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/13188\/revisions\/13500"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/media\/13272"}],"wp:attachment":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/media?parent=13188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/categories?post=13188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/tags?post=13188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}