Docker Compose installed, following Step 1 of How To Install Docker Compose on Ubuntu 20.04. Step 1 — Downloading Laravel and Installing Dependencies. As a first step, you will get the latest version of Laravel and install the dependencies for the project, including Composer, the application-level package manager for PHP. We will install. For an overview of the autoscale architecture, take a look at the comprehensive documentation on autoscaling. Forked version of Docker machine. Because docker-machine is in maintenance mode, GitLab is providing it’s own fork of docker-machine, which is based on the latest main branch of docker-machine with some additional patches for the following bugs. These docker images are configured in docker-compose.yml file and also the production version is docker-compose.production.yml. If you're not using Vuejs with your Laravel application, you can simply comment the npm container.
Step 1: Download Laravel to your local machine
If you don’t have Laravel in your local machine, install it first by cloning it by git command.
Step 2 : Create Docker Compose File
After installing Laravel in your local machine, proceed to your Laravel project directory by typing:
You can open you Visual Studio Code so you can see the file structure of Laravel and to observe what is the purpose of the following commands.
To create docker-compose.yml and its related directory files, type the following commands in terminal:
Go to .docker directory and create required files by typing:
Open Visual Studio Code and go to Laravel app. Navigate to the files you created earlier then copy and paste the following then save.
The docker-compose.yml should look like the below example. Copy and paste the following then save (CTRL + S):
Under the .docker directory, open vhost.conf and paste the following then save:
Step 3: Start Laravel Application with Docker Compose
Now that you saved the changes in the required files, go to your terminal then type:
If it results in error, try putting sudo before it:
Check it is it running by typing the following. If it doesn’t show, try putting sudo before it.
Access the hosting machine through the container id i.e. 83ad4ef2b5dc as per the screenshot by typing the following. Try adding sudo if it doesn’t work and make sure to change the container ID.
Then type ls -la to check its existing files. install composer by typing the following and wait for it to finish:
After the installation, type EXIT. Open your browser then navigate your localhost with port 8080.
If it shows you the Laravel page, you successfully containerized your Laravel app. But if it shows the following error, proceed to next steps.
In your terminal, type the following:
Then run the laravelapp containers by typing the following without using sudo:
Type again in your browser your localhost with port 8080.
Step 4: Laravel Database Connection in Docker
Now we have to connect the database to our Laravel application. Which is pretty simple though the
.env file. Go to Visual Studio Code and change the following according to database we created earlier.
Go to your terminal and type:
Then migrate by typing:
Laravel Docker Composer Installer
You have now successfully installed Laravel in a docker container.