I have a laravel 8 project created with composer. Then I added laravel sail by composer require laravel/sail
and then executed command php artisan sail:install
.
After sail up
command, only mysql
container was created and everything works well. But now I want to add redis
to my docker container. How can I do this? I have no knowledge with Docker but laravel sail has made it very easy to use Docker. I want to add redis
with the help of laravel sail. Is there any way to do that?
3
Answers
you can edit
docker-compose.yml
In the
services
then finally, in
volumes:
You may also can start a fresh new project with
then refer the generated
docker-compose.yml
after you edit, save it then run
./vendor/bin/sail build
then onlysaild up -d
I know it is not the best solution but I think it’s so easy.
Update your
docker-compose.yml
file using following lines:You can just issue the command
php artisan sail:install
againNow select the services you need and separate them with
,
So for example
0, 3, 7
This will update your
docker-compose.yml
file and add the lines forMySQL, Redis, Mailhog
. It might overwrite some of your old settings though!Once you start sail again it will pull the services and you’re good to go.