{"id":62,"date":"2023-08-05T07:15:04","date_gmt":"2023-08-05T07:15:04","guid":{"rendered":"http:\/\/it4home.dk\/?p=62"},"modified":"2023-08-06T09:24:19","modified_gmt":"2023-08-06T09:24:19","slug":"setting-up-drupal-with-docker-compose","status":"publish","type":"post","link":"https:\/\/it4home.dk\/index.php\/2023\/08\/05\/setting-up-drupal-with-docker-compose\/","title":{"rendered":"Setting Up Drupal with Docker Compose"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/62?print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><\/a><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/62?print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"https:\/\/it4home.dk\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">Introduction:<br>Drupal is a popular content management system that allows you to create and manage websites with ease. By using Docker, we can quickly set up Drupal along with its MariaDB database, making the deployment process straightforward and portable. In this guide, we&#8217;ll show you how to run Drupal and MariaDB containers with Docker Compose.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 1: Install Docker and Docker Compose<br>Before proceeding, ensure you have Docker and Docker Compose installed on your system. If not, follow the official Docker installation instructions for your operating system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 2: Create a Docker Compose File<br>Create a new directory for your Drupal project and navigate into it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir drupal_project\ncd drupal_project<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inside the <code>drupal_project<\/code> directory, create a <code>docker-compose.yml<\/code> file using a text editor of your choice (e.g., <code>nano<\/code>, <code>vi<\/code>, or <code>vim<\/code>), and add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3'\n\nservices:\n  drupaldb:\n    image: mariadb:latest\n    environment:\n      MYSQL_ROOT_PASSWORD: drupal\n      MYSQL_DATABASE: drupal\n    volumes:\n      - drupal_mariadb_data:\/var\/lib\/mysql\n    container_name: drupaldb\n    restart: always\n\n  drupal:\n    image: drupal:latest\n    ports:\n      - \"80:80\"\n    environment:\n      DRUPAL_DB_USER: root\n      DRUPAL_DB_PASSWORD: drupal\n    volumes:\n      - drupal_data:\/var\/www\/html\n    container_name: drupal\n    depends_on:\n      - drupaldb\n    restart: always\n\nvolumes:\n  drupal_mariadb_data:\n  drupal_data:<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 3: Start the Containers<br>To create and start the Drupal and MariaDB containers, run the following command inside the <code>drupal_project<\/code> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker-compose up -d<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Docker Compose will pull the required images (if not already available locally) and start the containers in the background.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 4: Access Drupal<br>Once the containers are running, you can access your Drupal site by opening a web browser and navigating to <code>http:\/\/localhost<\/code>. The Drupal installation wizard will guide you through the setup process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 5: Cleanup<br>If you want to stop and remove the containers and volumes created by Docker Compose, use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker-compose down<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Conclusion:<br>Congratulations! You&#8217;ve successfully set up Drupal with Docker Compose, providing a scalable and easily manageable environment for your website. Docker Compose simplifies the process of managing multi-container applications, making it ideal for running Drupal alongside its MariaDB database. Now you can focus on building your Drupal website without worrying about the complexities of server setup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Happy Drupal development!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:Drupal is a popular content management system that allows you to create and manage websites with ease. By using Docker, we can quickly set up Drupal along with its MariaDB database, making the deployment&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":213,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[35],"class_list":["post-62","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-ok"],"_links":{"self":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":2,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":144,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/62\/revisions\/144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media\/213"}],"wp:attachment":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}