Skip to main content

Command Palette

Search for a command to run...

Dockerizing Laravel Project Step-By-Step

Updated
2 min read
Dockerizing Laravel Project Step-By-Step
L

I've got accomplished web development with expertise in various programming languages including PHP, Laravel, C#, and C++. My curiosity to learn more and my passion for coding drives me to constantly enhance my skills and create exceptional digital experiences.

Setting up Docker files

  1. Visit this blog first to shift normal Laravel project to sail Laravel

  2. Open Laravel Project in the code editor

  3. Now make a docker file like the one shown below

  4. make another file named 'Docker-compose.yml'

  5. Also, make a folder named Docker and inside that docker file I'll be creating a file titled entrypoint.sh

  1. Run a command in terminal

    Building Database Container.

  2. For the database container, I'll be working in the docker-compose.yml file which was inside the Docker folder I've created above.

    Use Laravel-Sail up

  3. a. composer requires laravel/sail --dev

    docker works with Laravel sail that's why I have executed the overhead command

  4. b.php artisan sail:install -> for installing services like MySQL and stuff

Thereafter I'll be running docker commands 'docker compose up --build'

Docker build container

when we'll do enter sail commands than.yml file will setup automatically

Docker File Content

This entire content will be set up when you will install the sail-laravel.

Docker-Desktop

After following the above procedure in the terminal write

docker-compose up --build

and the container will have a similar look to that displayed below in the docker desktop


Feel free to ask your queries.