{"id":1,"date":"2023-12-12T10:41:35","date_gmt":"2023-12-12T10:41:35","guid":{"rendered":"https:\/\/200oksolutionssandbox.co.uk\/blog\/?p=1"},"modified":"2024-07-30T08:58:45","modified_gmt":"2024-07-30T08:58:45","slug":"dockerize-your-laravel-application","status":"publish","type":"post","link":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/","title":{"rendered":"Dockerize Your Laravel Application"},"content":{"rendered":"\n<p>How to Install Laravel with Docker<\/p>\n\n\n\n<p>Before we dive into the installation steps, make sure you have the necessary system requirements and Windows edition to run Docker Desktop. Here&#8217;s a simplified guide to get Laravel up and running with Docker.<\/p>\n\n\n\n<p><strong>System Requirements<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Windows 11 (64-bit): Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.<\/li>\n\n\n\n<li>Windows 10 (64-bit): Home or Pro 21H2 (build 19045) or higher, or Enterprise or Education 21H2 (build 19045) or higher.<\/li>\n\n\n\n<li>Ensure WSL 2 (Windows Subsystem for Linux 2) is enabled on Windows. Refer to Microsoft&#8217;s documentation for instructions.<\/li>\n<\/ul>\n\n\n\n<p><strong>Hardware Prerequisites<\/strong><\/p>\n\n\n\n<p>For Windows 10 or 11, you&#8217;ll need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>64-bit processor with Second Level Address Translation (SLAT)<\/li>\n\n\n\n<li>4GB system RAM<\/li>\n\n\n\n<li>BIOS-level hardware virtualization support enabled<\/li>\n<\/ul>\n\n\n\n<p><strong>Important Note<\/strong><\/p>\n\n\n\n<p>Running Windows containers requires Windows 10 or 11 Professional or Enterprise edition. Windows Home or Education editions only support Linux containers.<\/p>\n\n\n\n<p><strong>Installation Steps<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download Docker Desktop<\/strong>&nbsp;for Windows from their official website.<\/li>\n\n\n\n<li>Run the installer by double-clicking on &#8220;Docker Desktop Installer.exe.&#8221;<\/li>\n\n\n\n<li>During installation, select the &#8220;Use WSL 2 instead of Hyper-V&#8221; option if available.\n<ul class=\"wp-block-list\">\n<li>Note: If your system supports only one option, you won&#8217;t have a choice in the backend.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Follow the installation wizard&#8217;s instructions to authorize the installer and complete the process.<\/li>\n\n\n\n<li>After successful installation, select &#8220;Close.&#8221; Docker will ask you to log out and back into your Windows session or restart your machine to finish the installation.<\/li>\n<\/ol>\n\n\n\n<p><strong>Starting Docker Desktop<\/strong><\/p>\n\n\n\n<p>After the restart:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start Docker Desktop by searching for it in the start menu.<\/li>\n\n\n\n<li>The first time you run Docker, it may take a few minutes to configure itself.<\/li>\n\n\n\n<li>Open a command prompt or PowerShell window.<\/li>\n\n\n\n<li>Run the command&nbsp;<code>docker --version<\/code>&nbsp;to ensure Docker is installed and running.<\/li>\n<\/ol>\n\n\n\n<p><strong>Setting Up Laravel with Docker<\/strong><\/p>\n\n\n\n<p><strong>Dockerfile<\/strong><\/p>\n\n\n\n<p>Create a Dockerfile in your Laravel project&#8217;s root directory with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-silver-blue-background-color has-text-color has-background has-link-color wp-elements-ad3c56ab1a8d28e7e6bb8dbcb9c6c095\"><code>FROM php:8.1.0-apache\n\nWORKDIR \/var\/www\/html\n\n# Install required dependencies\nRUN a2enmod rewrite\nRUN apt-get update &amp;&amp; apt-get -y install gcc mono-mcs &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*\nRUN apt-get update -y &amp;&amp; apt-get install -y libicu-dev libmariadb-dev unzip zip zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev default-libmysqlclient-dev gcc\nRUN apt-get -y update; apt-get -y install curl\n\n# Install Composer\nCOPY --from=composer:latest \/usr\/bin\/composer \/usr\/bin\/composer\n\n# Install PHP extensions\nRUN docker-php-ext-install gettext intl pdo_mysql gd\nRUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg &amp;&amp; docker-php-ext-install -j$(nproc) gd\n<\/code><\/pre>\n\n\n\n<p><strong>docker-compose.yml<\/strong><\/p>\n\n\n\n<p>Create a docker-compose.yml file in your Laravel project&#8217;s root directory:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-silver-blue-background-color has-text-color has-background has-link-color wp-elements-557b5c0abbc87018a45c5521c5ea5329\"><code>services:\n  laravel-docker:\n    container_name: laravel-docker\n    build: .\n    volumes:\n      - .\/laravel-app:\/var\/www\/html\n    ports:\n      - 9000:80\n    extra_hosts:\n      - \"192.168.0.188:9000\"\n\n  mysql_db:\n    image: mysql:latest\n    environment:\n      MYSQL_ROOT_PASSWORD: root\n      MYSQL_DATABASE: laravel_docker\n    ports:\n    - 3306:3306\n\n  phpmyadmin:\n    image: phpmyadmin:latest\n    ports:\n      - 9001:80\n    environment:\n      - PMA_ARBITRARY=1\n<\/code><\/pre>\n\n\n\n<p><strong>Running Docker Containers<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to your Laravel project&#8217;s base directory in the command prompt.<\/li>\n\n\n\n<li>Execute\u00a0<code><strong>docker-compose build<\/strong><\/code>\u00a0to build the Docker containers.<\/li>\n\n\n\n<li>Launch the application with\u00a0<strong><code>docker-compose up<\/code>.<\/strong><\/li>\n\n\n\n<li>Access the Docker container with\u00a0<code><strong>docker exec -it laravel-docker bash<\/strong><\/code>. Replace &#8220;laravel-docker&#8221; with your container&#8217;s name if different.<\/li>\n<\/ol>\n\n\n\n<p><strong>Install Laravel and Configure Database<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Install Laravel using the command:\u00a0<code><strong>composer create-project laravel\/laravel .<\/strong><\/code><\/li>\n\n\n\n<li>Once Laravel is installed, execute the\u00a0<code><strong>exit<\/strong><\/code>\u00a0command.<\/li>\n<\/ol>\n\n\n\n<p><strong>Modify the .env File<\/strong><\/p>\n\n\n\n<p>Update the database connection details in the .env file with these settings:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-silver-blue-background-color has-text-color has-background has-link-color wp-elements-0297a36262470d10e2dd29d5e0a18fd5\"><code>DB_CONNECTION=mysql\nDB_HOST=mysql_db\nDB_PORT=3306\nDB_DATABASE=laravel_docker\nDB_USERNAME=root\nDB_PASSWORD=root\n<\/code><\/pre>\n\n\n\n<p><strong>Execute Migrations<\/strong><\/p>\n\n\n\n<p>Run the migrations using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-silver-blue-background-color has-text-color has-background has-link-color wp-elements-8f45fa5340c4abe4aae06949762e3d43\"><code>docker exec laravel-docker bash -c \"php artisan migrate\"\n<\/code><\/pre>\n\n\n\n<p>Now, your Laravel project should be accessible at&nbsp;<a href=\"http:\/\/localhost:9000\/public\/\">http:\/\/localhost:9000\/public\/<\/a>, and you can manage your database with PHPMyAdmin at&nbsp;<a href=\"http:\/\/localhost:9001\/\">http:\/\/localhost:9001\/<\/a>. Enjoy developing with Laravel and Docker!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install Laravel with Docker Before we dive into the installation steps, make sure&hellip;<\/p>\n","protected":false},"author":1,"featured_media":14,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Dockerize Your Laravel Application<\/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:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dockerize Your Laravel Application\" \/>\n<meta property=\"og:description\" content=\"How to Install Laravel with Docker Before we dive into the installation steps, make sure&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/profile.php?id=61552217825863\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-12T10:41:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-30T08:58:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"866\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"BlogAdmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"BlogAdmin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dockerize Your Laravel Application","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:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/","og_locale":"en_US","og_type":"article","og_title":"Dockerize Your Laravel Application","og_description":"How to Install Laravel with Docker Before we dive into the installation steps, make sure&hellip;","og_url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/","article_publisher":"https:\/\/www.facebook.com\/profile.php?id=61552217825863","article_published_time":"2023-12-12T10:41:35+00:00","article_modified_time":"2024-07-30T08:58:45+00:00","og_image":[{"width":900,"height":866,"url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg","type":"image\/jpeg"}],"author":"BlogAdmin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"BlogAdmin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#article","isPartOf":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/"},"author":{"name":"BlogAdmin","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#\/schema\/person\/ea0b72006227b3403f5ad825b82ced43"},"headline":"Dockerize Your Laravel Application","datePublished":"2023-12-12T10:41:35+00:00","dateModified":"2024-07-30T08:58:45+00:00","mainEntityOfPage":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/"},"wordCount":430,"commentCount":0,"publisher":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#organization"},"image":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#primaryimage"},"thumbnailUrl":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/","url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/","name":"Dockerize Your Laravel Application","isPartOf":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#primaryimage"},"image":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#primaryimage"},"thumbnailUrl":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg","datePublished":"2023-12-12T10:41:35+00:00","dateModified":"2024-07-30T08:58:45+00:00","breadcrumb":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#primaryimage","url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg","contentUrl":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2023\/12\/Docker-Laravel.jpg","width":900,"height":866},{"@type":"BreadcrumbList","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/dockerize-your-laravel-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/200oksolutionssandbox.co.uk\/blog\/"},{"@type":"ListItem","position":2,"name":"Dockerize Your Laravel Application"}]},{"@type":"WebSite","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#website","url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/","name":"","description":"","publisher":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/200oksolutionssandbox.co.uk\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#organization","name":"Web Development Blog | Software Blog | App Blog","url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2026\/01\/200ok_logo.png","contentUrl":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-content\/uploads\/2026\/01\/200ok_logo.png","width":500,"height":191,"caption":"Web Development Blog | Software Blog | App Blog"},"image":{"@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/profile.php?id=61552217825863"]},{"@type":"Person","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#\/schema\/person\/ea0b72006227b3403f5ad825b82ced43","name":"BlogAdmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/200oksolutionssandbox.co.uk\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/53ecc99d859b4d3444ee1e076f3b5d9da9962836d1c20b3b44d73574f435740d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/53ecc99d859b4d3444ee1e076f3b5d9da9962836d1c20b3b44d73574f435740d?s=96&d=mm&r=g","caption":"BlogAdmin"},"sameAs":["http:\/\/blog.200oksolutions.com"],"url":"https:\/\/200oksolutionssandbox.co.uk\/blog\/author\/blogadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":4,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":885,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions\/885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/media\/14"}],"wp:attachment":[{"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/200oksolutionssandbox.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}