<p>You might use the <code>--no-cache</code> option if you want full rebuilding (<code>docker-compose build --no-cache {container-name}</code>).</p>
<p>To add an image (software), just edit the <code>docker-compose.yml</code> and add your container details, to do so you need to be familiar with the <a href="https://docs.docker.com/compose/compose-file/">docker compose file syntax</a>.</p>
<p>Before installing PHP extensions, you have to decide whether you need for the <code>FPM</code> or <code>CLI</code> because each lives on a different container, if you need it for both you have to edit both containers.</p>
<p>The PHP-FPM extensions should be installed in <code>php-fpm/Dockerfile-XX</code>. <em>(replace XX with your default PHP version number)</em>.
<br>
The PHP-CLI extensions should be installed in <code>workspace/Dockerfile</code>.</p>
<p>The PHP-FPM is responsible of serving your application code, you don&rsquo;t have to change the PHP-CLI version if you are planning to run your application on different PHP-FPM version.</p>
<p>1 - Open the <code>docker-compose.yml</code>.</p>
<p>2 - Search for <code>Dockerfile-70</code> in the PHP container section.</p>
<p>3 - Change the version number, by replacing <code>Dockerfile-70</code> with <code>Dockerfile-56</code>, like this:</p>
<p>For more details about the PHP base image, visit the <a href="https://hub.docker.com/_/php/">official PHP docker images</a>.</p>
<h3 id="b-switch-from-php-7-0-or-5-6-to-php-5-5">B) Switch from PHP <code>7.0</code> or <code>5.6</code> to PHP <code>5.5</code></h3>
<p>Note: it&rsquo;s not very essential to edit the PHP-CLI version. The PHP-CLI is only used for the Artisan Commands &amp; Composer. It doesn&rsquo;t serve your Application code, this is the PHP-FPM job.</p>
<p>The PHP-CLI is installed in the Workspace container. To change the PHP-CLI version you need to edit the <code>workspace/Dockerfile</code>.</p>
<p>Right now you have to manually edit the <code>Dockerfile</code> or create a new one like it&rsquo;s done for the PHP-FPM. (consider contributing).</p>
<p>2 - Re-build the containers <code>docker-compose build workspace php-fpm</code></p>
<p>3 - Open <code>laradock/workspace/xdebug.ini</code> and/or <code>laradock/php-fpm/xdebug.ini</code> and enable at least the following configurations:</p>
<pre><code>xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=1
</code></pre>
<p>For information on how to configure xDebug with your IDE and work it out, check this <a href="https://github.com/LarryEitel/laravel-laradock-phpstorm">Repository</a>.</p>
<p>To control the behavior of xDebug (in the <code>php-fpm</code> Container), you can run the following commands from the Laradock root folder, (at the same prompt where you run docker-compose):</p>
<p>Note: If <code>./xdebugPhpFpm</code> doesn&rsquo;t execute and gives <code>Permission Denied</code> error the problem can be that file <code>xdebugPhpFpm</code> doesn&rsquo;t have execution access. This can be fixed by running <code>chmod</code> command with desired access permissions.</p>
<p>It&rsquo;s recommended for production to create a custom <code>docker-compose.yml</code> file. For that reason, Laradock is shipped with <code>production-docker-compose.yml</code> which should contain only the containers you are planning to run on production (usage example: <code>docker-compose -f production-docker-compose.yml up -d nginx mysql redis ...</code>).</p>
<p>Note: The Database (MySQL/MariaDB/&hellip;) ports should not be forwarded on production, because Docker will automatically publish the port on the host, which is quite insecure, unless specifically told not to. So make sure to remove these lines:</p>
<p>To learn more about how Docker publishes ports, please read <a href="https://fralef.me/docker-and-iptables.html">this excellent post on the subject</a>.</p>
<p>We recommend using <code>composer create-project</code> instead of the Laravel installer, to install Laravel.</p>
</blockquote>
<p>For more about the Laravel installation click <a href="https://laravel.com/docs/master#installing-laravel">here</a>.</p>
<p>3 - Edit <code>docker-compose.yml</code> to Map the new application path:</p>
<p>Since the new Laravel application is in the <code>my-cool-app</code> folder, we need to replace <code>../:/var/www</code> with <code>../my-cool-app/:/var/www</code>, as follow:</p>
<p>Add <code>--user=laradock</code> (example <code>docker-compose exec --user=laradock workspace bash</code>) to have files created as your host&rsquo;s user.</p>
<p>1 - First make sure you run the Redis Container (<code>redis</code>) with the <code>docker-compose up</code> command.</p>
<pre><code class="language-bash">docker-compose up -d redis
<p>2 - Open your Laravel&rsquo;s <code>.env</code> file and set the <code>REDIS_HOST</code> to <code>redis</code></p>
<p>If you don&rsquo;t find the <code>REDIS_HOST</code> variable in your <code>.env</code> file. Go to the database configuration file <code>config/database.php</code> and replace the default <code>127.0.0.1</code> IP with <code>redis</code> for Redis like this:</p>
<p>3 - To enable Redis Caching and/or for Sessions Management. Also from the <code>.env</code> file set <code>CACHE_DRIVER</code> and <code>SESSION_DRIVER</code> to <code>redis</code> instead of the default <code>file</code>.</p>
<p>4 - Finally make sure you have the <code>predis/predis</code> package <code>(~1.0)</code> installed via Composer:</p>
<li>set the <code>DB_HOST</code> to your <code>mongo</code>.</li>
<li>set the <code>DB_PORT</code> to <code>27017</code>.</li>
<li>set the <code>DB_DATABASE</code> to <code>database</code>.</li>
</ul>
<p>6 - Finally make sure you have the <code>jenssegers/mongodb</code> package installed via Composer and its Service Provider is added.</p>
<p>More details about this <a href="https://github.com/jenssegers/laravel-mongodb#installation">here</a>.</p>
<p>7 - Test it:</p>
<ul>
<li>First let your Models extend from the Mongo Eloquent Model. Check the <a href="https://github.com/jenssegers/laravel-mongodb#eloquent">documentation</a>.</li>
<li>Enter the Workspace Container.</li>
<li>Migrate the Database <code>php artisan migrate</code>.</li>
<p>1 - Run the phpMyAdmin Container (<code>phpmyadmin</code>) with the <code>docker-compose up</code> command. Example:</p>
<pre><code class="language-bash"># use with mysql
docker-compose up -d mysql phpmyadmin
# use with mariadb
docker-compose up -d mariadb phpmyadmin
</code></pre>
<p>2 - Open your browser and visit the localhost on port <strong>8080</strong>: <code>http://localhost:8080</code></p>
<p>1 - Run the pgAdmin Container (<code>pgadmin</code>) with the <code>docker-compose up</code> command. Example:</p>
<pre><code class="language-bash">docker-compose up -d postgres pgadmin
</code></pre>
<p>2 - Open your browser and visit the localhost on port <strong>5050</strong>: <code>http://localhost:5050</code></p>
<p>1 - Run the Beanstalkd Container:</p>
<pre><code class="language-bash">docker-compose up -d beanstalkd
</code></pre>
<p>2 - Configure Laravel to connect to that container by editing the <code>config/queue.php</code> config file.</p>
<p>a. first set <code>beanstalkd</code> as default queue driver
b. set the queue host to beanstalkd : <code>QUEUE_HOST=beanstalkd</code></p>
<p><em>beanstalkd is now available on default port <code>11300</code>.</em></p>
<p>3 - Require the dependency package <a href="https://github.com/pda/pheanstalk">pda/pheanstalk</a> using composer.</p>
<p>Optionally you can use the Beanstalkd Console Container to manage your Queues from a web interface.</p>
<p>1 - Run the Beanstalkd Console Container:</p>
<pre><code class="language-bash">docker-compose up -d beanstalkd-console
</code></pre>
<p>2 - Open your browser and visit <code>http://localhost:2080/</code></p>
<p>1 - Run the ElasticSearch Container (<code>elasticsearch</code>) with the <code>docker-compose up</code> command:</p>
<pre><code class="language-bash">docker-compose up -d elasticsearch
</code></pre>
<p>2 - Open your browser and visit the localhost on port <strong>9200</strong>: <code>http://localhost:9200</code></p>
<p>1 - Install the ElasticSearch plugin like <a href="https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugins-delete-by-query.html">delete-by-query</a>.</p>
<p>1 - Run the Selenium Container (<code>selenium</code>) with the <code>docker-compose up</code> command. Example:</p>
<pre><code class="language-bash">docker-compose up -d selenium
</code></pre>
<p>2 - Open your browser and visit the localhost on port <strong>4444</strong> at the following URL: <code>http://localhost:4444/wd/hub</code></p>
<p>The RethinkDB is an open-source Database for Real-time Web (<a href="https://rethinkdb.com/">RethinkDB</a>).
A package (<a href="https://github.com/duxet/laravel-rethinkdb">Laravel RethinkDB</a>) is being developed and was released a version for Laravel 5.2 (experimental).</p>
<p>1 - Run the RethinkDB Container (<code>rethinkdb</code>) with the <code>docker-compose up</code> command.</p>
<pre><code class="language-bash">docker-compose up -d rethinkdb
</code></pre>
<p>2 - Access the RethinkDB Administration Console <a href="http://localhost:8090/#tables">http://localhost:8090/#tables</a> for create a database called <code>database</code>.</p>
<p>3 - Add the RethinkDB configurations to the <code>config/database.php</code> configuration file:</p>
- On the workspace container, change <code>INSTALL_MC</code> to true to get the client
- Set <code>MINIO_ACCESS_KEY</code> and <code>MINIO_ACCESS_SECRET</code> if you wish to set proper keys</p>
<p>2 - Run the Minio Container (<code>minio</code>) with the <code>docker-compose up</code> command. Example:</p>
<pre><code class="language-bash">docker-compose up -d minio
</code></pre>
<p>3 - Open your browser and visit the localhost on port <strong>9000</strong> at the following URL: <code>http://localhost:9000</code></p>
<p>4 - Create a bucket either through the webui or using the mc client:</p>
<pre><code class="language-bash"> mc mb minio/bucket
</code></pre>
<p>5 - When configuring your other clients use the following details:</p>
<p>To change the timezone for the <code>workspace</code> container, modify the <code>TZ</code> build argument in the Docker Compose file to one in the <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">TZ database</a>.</p>
<p>For example, if I want the timezone to be <code>New York</code>:</p>
<p>We also recommend <a href="http://www.camroncade.com/managing-timezones-with-laravel/">setting the timezone in Laravel</a>.</p>
<p>Make sure you <a href="#Change-the-timezone">change the timezone</a> if you don&rsquo;t want to use the default (UTC).</p>
<p>You can access the <code>workspace</code> container through <code>localhost:2222</code> by setting the <code>INSTALL_WORKSPACE_SSH</code> build argument to <code>true</code>.</p>
<p>To change the default forwarded port for ssh:</p>
<p>You can forward the MySQL/MariaDB port to your host by making sure these lines are added to the <code>mysql</code> or <code>mariadb</code> section of the <code>docker-compose.yml</code> or in your <a href="https://docs.docker.com/compose/extends/">environment specific Compose</a> file.</p>
<p>The default username and password for the root MySQL user are <code>root</code> and <code>root</code>.</p>
<p>1 - Enter the MySQL container: <code>docker-compose exec mysql bash</code>.</p>
<p>2 - Enter mysql: <code>mysql -uroot -proot</code> for non root access use <code>mysql -uhomestead -psecret</code>.</p>
<p>3 - See all users: <code>SELECT User FROM mysql.user;</code></p>
<p>4 - Run any commands <code>show databases</code>, <code>show tables</code>, <code>select * from.....</code>.</p>
<p>Modify the <code>mysql/my.cnf</code> file to set your port number, <code>1234</code> is used as an example.</p>
<pre><code>[mysqld]
port=1234
</code></pre>
<p>If you need <a href="#MySQL-access-from-host">MySQL access from your host</a>, do not forget to change the internal port number (<code>&quot;3306:3306&quot;</code> -&gt; <code>&quot;3306:1234&quot;</code>) in the docker-compose configuration file.</p>
<p>Assuming your custom domain is <code>laravel.dev</code></p>
<p>1 - Open your <code>/etc/hosts</code> file and map your localhost address <code>127.0.0.1</code> to the <code>laravel.dev</code> domain, by adding the following:</p>
<p>Enabling Global Composer Install during the build for the container allows you to get your composer requirements installed and available in the container after the build is done.</p>
<p>1 - Open the <code>docker-compose.yml</code> file</p>
<p>2 - Search for the <code>COMPOSER_GLOBAL_INSTALL</code> argument under the Workspace Container and set it to <code>true</code></p>
<p><a href="https://github.com/hirak/prestissimo">Prestissimo</a> is a plugin for composer which enables parallel install functionality.</p>
<p>1 - Enable Running Global Composer Install during the Build:</p>
<p>Click on this <a href="#Enable-Global-Composer-Build-Install">Enable Global Composer Build Install</a> and do steps 1 and 2 only then continue here.</p>
<p>2 - Add prestissimo as requirement in Composer:</p>
<p>a - Now open the <code>workspace/composer.json</code> file</p>
<p>b - Add <code>&quot;hirak/prestissimo&quot;: &quot;^0.3&quot;</code> as requirement</p>
<p>c - Re-build the Workspace Container <code>docker-compose build workspace</code></p>
<p>To install NVM and NodeJS in the Workspace container</p>
<p>1 - Open the <code>docker-compose.yml</code> file</p>
<p>2 - Search for the <code>INSTALL_NODE</code> argument under the Workspace Container and set it to <code>true</code></p>
<p>Yarn is a new package manager for JavaScript. It is so faster than npm, which you can find <a href="http://yarnpkg.com/en/compare">here</a>.To install NodeJS and <a href="https://yarnpkg.com/">Yarn</a> in the Workspace container:</p>
<p>1 - Open the <code>docker-compose.yml</code> file</p>
<p>2 - Search for the <code>INSTALL_NODE</code> and <code>INSTALL_YARN</code> argument under the Workspace Container and set it to <code>true</code></p>
<p>Linuxbrew is a package manager for Linux. It is the Linux version of MacOS Homebrew and can be found <a href="http://linuxbrew.sh">here</a>. To install Linuxbrew in the Workspace container:</p>
<p>1 - Open the <code>docker-compose.yml</code> file</p>
<p>2 - Search for the <code>INSTALL_LINUXBREW</code> argument under the Workspace Container and set it to <code>true</code></p>
<p>When you start your docker container, Laradock will copy the <code>aliases.sh</code> file located in the <code>laradock/workspace</code> directory and add sourcing to the container <code>~/.bashrc</code> file.</p>
<p>You are free to modify the <code>aliases.sh</code> as you see fit, adding your own aliases (or function macros) to suit your requirements.</p>
<li>Stop the docker VM <code>docker-machine stop {default}</code></li>
<li>Install Docker for <a href="https://docs.docker.com/docker-for-mac/">Mac</a> or <a href="https://docs.docker.com/docker-for-windows/">Windows</a>.</li>
<p>Sharing code into Docker containers with osxfs have very poor performance compared to Linux. You can get around this issue by using NFS to share your files betwen your host and your container.</p>
<blockquote>
<p>How to share files using NFS (d4m-nfs)</p>
</blockquote>
<p><a href="https://github.com/IFSight/d4m-nfs">d4m-nfs</a> automatically mount NFS volume instead of osxfs one.</p>
<p>1) Update the Docker [File Sharing] preferences:</p>
<p>Click on the Docker Icon &gt; Preferences &gt; (remove everything form the list except <code>/tmp</code>).</p>
<p>2) Restart Docker.</p>
<p>3) Clone the <a href="https://github.com/IFSight/d4m-nfs">d4m-nfs</a> repository to your <code>home</code> directory.</p>
<p>5) Create (or edit) the file <code>/etc/exports</code>, make sure it exists and is empty. (There may be collisions if you come from Vagrant or if you already executed the <code>d4m-nfs.sh</code> script before).</p>
<p>6) Run the <code>d4m-nfs.sh</code> script:</p>
<pre><code class="language-bash">docker-compose up -d nginx mysql
</code></pre>
<p><strong>Note:</strong> If you faced any errors, try restarting Docker, and make sure you have no spaces in the <code>d4m-nfs-mounts.txt</code> file, and your <code>/etc/exports</code> file is clear.</p>
<h2 id="i-see-a-blank-white-page-instead-of-the-laravel-welcome-page">I see a blank (white) page instead of the Laravel &lsquo;Welcome&rsquo; page!</h2>
<h2 id="i-see-welcome-to-nginx-instead-of-the-laravel-app">I see &ldquo;Welcome to nginx&rdquo; instead of the Laravel App!</h2>
<h2 id="i-see-an-error-message-containing-address-already-in-use-or-port-is-already-allocated">I see an error message containing <code>address already in use</code> or <code>port is already allocated</code></h2>
<p>Make sure the ports for the services that you are trying to run (22, 80, 443, 3306, etc.) are not being used already by other programs on the host, such as a built in <code>apache</code>/<code>httpd</code> service or other development tools you have installed.</p>
<p>This error sometimes happens because your Laravel application isn&rsquo;t running on the container localhost IP (Which is 127.0.0.1). Steps to fix it:</p>
<li>Check your running Laravel application IP by dumping <code>Request::ip()</code> variable using <code>dd(Request::ip())</code> anywhere on your application. The result is the IP of your Laravel container.</li>
<li>Change the <code>DB_HOST</code> variable on env with the IP that you received from previous step.</li>
<li>Change the <code>DB_HOST</code> value to the same name as the MySQL docker container. The Laradock docker-compose file currently has this as <code>mysql</code></li>