<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Urwah</title>
    <description>The latest articles on DEV Community by Muhammad Urwah (@urwah1248).</description>
    <link>https://dev.to/urwah1248</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F947761%2F62044448-fce9-486c-9cf6-cc8a10e00f57.png</url>
      <title>DEV Community: Muhammad Urwah</title>
      <link>https://dev.to/urwah1248</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/urwah1248"/>
    <language>en</language>
    <item>
      <title>WordPress with Docker Desktop and Docker Compose</title>
      <dc:creator>Muhammad Urwah</dc:creator>
      <pubDate>Tue, 04 Jul 2023 17:48:33 +0000</pubDate>
      <link>https://dev.to/urwah1248/wordpress-with-docker-desktop-and-docker-compose-3n9k</link>
      <guid>https://dev.to/urwah1248/wordpress-with-docker-desktop-and-docker-compose-3n9k</guid>
      <description>&lt;p&gt;In this guide, you will learn how to set up and use WordPress with Docker Desktop using Docker Compose. Using this method will make you stop using XAMPP, LAMP or WAMP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before proceeding, make sure you have the following prerequisites installed on your system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker Desktop: Download and install Docker Desktop from the official &lt;a href="https://www.docker.com/products/docker-desktop/"&gt;Docker website&lt;/a&gt; for your operating system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Create a Docker Compose file
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your favorite text editor such as VS Code.&lt;/li&gt;
&lt;li&gt;Create a new file named &lt;code&gt;docker-compose.yaml&lt;/code&gt; in the directory of your choice.&lt;/li&gt;
&lt;li&gt;Copy and paste the following content into the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file and then make sure to save the file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.8'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# We use a mariadb image which supports both amd64 &amp;amp; arm64 architecture&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mariadb:10.6.4-focal&lt;/span&gt;
    &lt;span class="c1"&gt;# If you really want to use MySQL, uncomment the following line&lt;/span&gt;
    &lt;span class="c1"&gt;# image: mysql:8.0.27&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--default-authentication-plugin=mysql_native_password'&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db_data:/var/lib/mysql&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MYSQL_ROOT_PASSWORD=somewordpress&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MYSQL_DATABASE=wordpress&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MYSQL_USER=wordpress&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MYSQL_PASSWORD=wordpress&lt;/span&gt;
    &lt;span class="na"&gt;expose&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="m"&gt;3306&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="m"&gt;33060&lt;/span&gt;
  &lt;span class="na"&gt;wordpress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wordpress:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;80:80&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;WORDPRESS_DB_HOST=db&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;WORDPRESS_DB_USER=wordpress&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;WORDPRESS_DB_PASSWORD=wordpress&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;WORDPRESS_DB_NAME=wordpress&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db_data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Start the WordPress container
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open Docker Desktop on your system.&lt;/li&gt;
&lt;li&gt;In the Docker Desktop interface, navigate to the folder where you saved the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Click on the "Compose" button in the Docker Desktop interface.&lt;/li&gt;
&lt;li&gt;Select the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file you created.&lt;/li&gt;
&lt;li&gt;Click on the "Run" button to start the WordPress container.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker Desktop will pull the required images and start the containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Access WordPress in your browser
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your web browser.&lt;/li&gt;
&lt;li&gt;Enter the following URL in the address bar:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;http://localhost&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Follow the WordPress installation steps to set up your website and then you're good to go. It will be fully functional.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BFye9fl5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czq96i0fxs1wp5c6d6j5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BFye9fl5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czq96i0fxs1wp5c6d6j5.png" alt="Working Wordpress" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Stop and remove the containers
&lt;/h2&gt;

&lt;p&gt;If you want to stop and remove the WordPress containers, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Docker Desktop on your system.&lt;/li&gt;
&lt;li&gt;In the Docker Desktop interface, navigate to the folder where you saved the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Click on the "Compose" button.&lt;/li&gt;
&lt;li&gt;Select the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Click on the "Stop" button to stop the containers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker Desktop will stop and remove the containers, but it will retain the WordPress database and its data.&lt;/p&gt;

&lt;p&gt;Congratulations! You have successfully set up WordPress using Docker Desktop and Docker Compose. You can now manage and customize your WordPress website within the Docker environment.&lt;/p&gt;

&lt;p&gt;Remember to regularly backup your WordPress data to avoid data loss, and refer to the Docker documentation for more advanced configuration options and deployment scenarios.&lt;/p&gt;

&lt;p&gt;The Docker Compose code is taken from the &lt;a href="https://github.com/docker/awesome-compose"&gt;docker/awesome-compose&lt;/a&gt; github repository which contains many different templates for docker-compose.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
