Running multiple Laravel apps locally with Docker

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024
  • Want to learn more about how to develop and deploy Laravel applications with Docker? I've released a premium course featuring 23 videos for just $29! Check it out here: laraveldocker.com
    In this 13 minute video, I'll show you how to run two separate Laravel applications using local Docker networks and communicate between them.
    Join my weekly newsletter for tips on Laravel + more: aschmelyun.sub...
    Here's the repo for the docker-compose-laravel project mentioned in this video: github.com/asc...
    You'll learn how to:
    Configure docker-compose files for each app
    View each separate Laravel application in the browser
    Create a shareable bridge network in Docker
    Make an API call between apps using a Docker service hostname
    Follow me on Twitter! / aschmelyun
    Thanks Patreon supporters!
    Sam Ross
    PK
    Melissa Kipp
    Directly support these videos @ / aschmelyun

Комментарии • 78

  • @vabalokis
    @vabalokis 4 года назад +10

    I am starting to transition to docker env and these videos are gold

    • @meilyandevriyantimor5492
      @meilyandevriyantimor5492 4 года назад

      That's true. Those videos are a big help. Maybe @Andrew Schmelyun can give example for mount volume in the host machine and it permission

  • @gorazdveselic7022
    @gorazdveselic7022 4 года назад +4

    Great tutorial.
    With docker compose version 3.5 you can set network name. So you don't need to checl for it in app-two:
    networks:
    laravel:
    app-shared:
    driver: bridge
    name: app-shared

    • @aschmelyun
      @aschmelyun  4 года назад

      Nice! Thanks for the tip!

  • @itsMeSteveinix
    @itsMeSteveinix 4 года назад +3

    Your videos are helping me tremendously. Thank you so much for doing these. Hopefully you gain more subscribers since your videos are well made, easily understood and of high quality. More powers to you!

  • @a7ascape557
    @a7ascape557 2 года назад

    man this quick run is such a relief for the brain

  • @kasramy8845
    @kasramy8845 2 года назад +1

    Very helpful video! That would be great if you could show how to deploy multiple (laravel) apps in a VPS using docker containers!

  • @laurentcochet2893
    @laurentcochet2893 3 года назад +1

    just discovered your channel and I really enjoy your videos. Can't wait for you to discover traefik, I assumed this would be the subject of this video (I personnaly use it to run multiples stacks on my dev laptops) ! But hey, still some awesomeness for you to discover !
    One juste little tiny thing that bothers me every time , your syntax for routes, i find [Mycontroller::class, 'action'] instead of 'Mycontroller@action' soooo much more practical since I can ctrl-click the name of the controller ! ;)
    On a more important note, I would probably adress the very common issue of users difference between the host and the container, I've noted a comment related to this under this video.
    i for one add two arguments to the build section of my docker-compose :
    args:
    user: laurent
    uid: 1000
    That I use in the Dockerfile
    FROM php:8-fpm
    # Arguments defined in docker-compose.yml
    ARG user
    ARG uid
    .... blah blah blah install some cool stuff ...
    RUN useradd -G www-data,root -u $uid -d /home/$user $user
    RUN chown -R $user:$user /home/$user
    WORKDIR /var/www
    USER $user
    This way both users in the host and the container share the same name and the same id, preventing permissions errors for files created inside the container (like logs or cache files) with the default root user's id 1.

  • @JohnnyBigodes
    @JohnnyBigodes 4 года назад

    And again... Another video on point... Thank you

  • @memack101
    @memack101 4 года назад

    Great video and thank you. I will be trying this out.

  • @mokhosh
    @mokhosh 4 года назад

    Love your content. Keep it up man.

  • @user-jt4ye4yd7r
    @user-jt4ye4yd7r 9 месяцев назад

    Thanks for the help

  • @RiazUddinMasum
    @RiazUddinMasum 4 года назад

    awesome. i was looking for it.

  • @aArcziMetin2
    @aArcziMetin2 4 года назад +1

    Awesome ! Could you show us how to forward to some domain?

  • @dhonxeanbobis4210
    @dhonxeanbobis4210 4 года назад +1

    Thanks sir. This was a very good example on running microservices. Hopefully you can also add the tutorial for adding the domain. Also, is it possible to only access the second docker with only one authentication from the other one? Thank you :)

  • @murilolivorato1489
    @murilolivorato1489 2 года назад

    It worked , thanks so mutch .

    • @kabisu2012
      @kabisu2012 2 года назад

      Can i have the running success code ?
      I stuck in the cURL error 7 like forever

  • @latlov
    @latlov 4 года назад +10

    Can you continue this tutorial with deploying these two apps on production with Letsencrypt and domains /subdomain for the api and web app? Plz!!!!

    • @yuniorespinal9926
      @yuniorespinal9926 4 года назад +1

      I would also like to see a deployment video tutorial

    • @AlexGower
      @AlexGower 3 года назад

      @@yuniorespinal9926 I would also like to see a deployment video

  • @sujithm.p9776
    @sujithm.p9776 4 года назад

    Great! Thanks for the tutorial

  • @Shadow-gq7om
    @Shadow-gq7om Год назад

    Why the connection to mysql you just need to use the service name but not the connection between two laravel app?
    Is it because they resides in different docker-compose file?

  • @RemDaDesigner
    @RemDaDesigner 4 года назад

    Very helpful video, cheers

  • @michaelscofield2652
    @michaelscofield2652 4 года назад

    Thanks! Great video

  • @Khaos98
    @Khaos98 4 года назад

    This is really helpfull, thank you so much!

  • @netrox4404
    @netrox4404 4 года назад +2

    Important note
    You must also edit default nginx conf. At the line "fastcgi_pass php:9000;" you must substitute "php" with your php-fpm sevice name, otherwise nginx will not work properly.

    • @abdelghanitaleb652
      @abdelghanitaleb652 2 года назад

      how to do that

    • @khalidmarhoum8254
      @khalidmarhoum8254 Год назад

      Thanks, it saved a lot of time, it's actually the container name not the service name. can you please explain why this error is happening

  • @mnogokotin
    @mnogokotin 2 года назад

    thanks, it helps me alot )

  • @richardfan1780
    @richardfan1780 4 года назад +1

    This is really helpfull, thank you so much!
    but my question is: should I share some containers like npm when multiple apps? and if I have 5 apps, I must build and run 5 group of all nginx/mysql/npm/composer/and any other containers that might run out of my server resources

  • @youssoufouyabre8490
    @youssoufouyabre8490 3 года назад +1

    Can i use this docker compose config in production ?

  • @ahmadabuaysheh
    @ahmadabuaysheh 4 года назад

    Nice videos!! I hope you could do one for ssh access directly! Thank you man!

  • @geeqwind1170
    @geeqwind1170 4 года назад +1

    Thanks ! can you please make tutorial how to make : Laravel JWT Auth API with Socialite, How to make Realtime API with Laravel !

  • @hieponline21
    @hieponline21 2 года назад

    thanks

  • @danarsucipto3673
    @danarsucipto3673 2 года назад

    It seems the laravel app running inside docker is slow (at 12:33). How to address that issue?

  • @williamstickles6062
    @williamstickles6062 4 года назад +1

    I am using wsl2 ubuntu and I get this error. Any idea why?
    The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

  • @keramotulislam856
    @keramotulislam856 Год назад

    Hey Andrew, Thanks for making this tutorial. It helps me a lot.
    I'm running Laravel and WordPress following your process. But in the WordPress system, sometimes I get "File not found" on the browser page reload.
    Can you please help me with that?

  • @domjanzsoo
    @domjanzsoo 2 года назад

    I assume there is also a way to spin up only one nginx proxy container

  • @danygagnon8446
    @danygagnon8446 Год назад

    docker network ls to list the networks

  • @mhdomarbahra1678
    @mhdomarbahra1678 4 года назад +1

    Great vidoes, it would be so lovely, If you show us how to use reverse proxy with these configs, in order to map server_names to ports

    • @aschmelyun
      @aschmelyun  4 года назад +1

      I'll add that video idea to my list!

  • @irwinsharma
    @irwinsharma Год назад

    Hi is this the way to create microservices?

  • @Vindfrisk
    @Vindfrisk 4 года назад

    quality content

  • @izclubcom
    @izclubcom 4 года назад

    Why my container is so slow when load page, over 4 -> 5s , i tested with project laravel 8.x default. Please help me! Thank you so much

  • @frankfranklin5708
    @frankfranklin5708 4 года назад

    Can you create a video on how to use nuxtjs with laradock?

  • @tannercampbell
    @tannercampbell 4 года назад

    When using App_2 as the API for App_1 does it need to go through the web.php route? Could that that take place instead in the api.php?

  • @bernardchisumo4054
    @bernardchisumo4054 2 года назад

    Hi Andrew ,
    How do you create and install a self-signed wildcard cert for browser with cert.sh ?

  • @mouridamine3237
    @mouridamine3237 2 года назад

    hi andrew just i want to know how i can get the full premium cours of laravel and docker i am new member

  • @hazebartowski
    @hazebartowski 4 года назад

    hey let say i have a container running at nginx port 80:80 and 127.0.0.1 for dev.example.test. how do i run another project say for dev.hello.test?

  • @samworldpk
    @samworldpk Год назад

    how can we use traefik in this same setup to eliminate the port in urls for poper working with cookies and other stuff same like in production.

    • @aschmelyun
      @aschmelyun  Год назад

      You can set Traefik up so that it acts as a proxy for your container network. You can set a Host that routes to a specific container, without the need for ports. So you can have two containers, with your-domain.com pointing to Container A, and api.your-domain.com pointing to Container B without any exposed ports on either (besides :80 and :443).
      The Traefik docs are a pretty good place to get started!

  • @matinnejatbakhsh2501
    @matinnejatbakhsh2501 4 месяца назад

    Awesome =))))

  • @Paltibenlaish
    @Paltibenlaish 3 года назад

    hi, is it possible to instead of using localhost to use the name of your domain
    I can do that on ubuntu in etc/hosts
    but in mac?

  • @dexter-2633
    @dexter-2633 4 года назад

    Can you please share how your development environment. Like fonts, themes, etc. Until today, I feel my current development environment is good but I don't feel content.

    • @aschmelyun
      @aschmelyun  4 года назад

      I just built a page for this on my website! Check out aschmelyun.com/uses it has everything I use on there.

  • @sujithm.p9776
    @sujithm.p9776 4 года назад

    How do we use bash for second MySQL service

  • @drwhowho
    @drwhowho 2 года назад

    Thanks, I am going to ignore docker completely, I see no use for it

  • @SimonDaviesOfCourse
    @SimonDaviesOfCourse 4 года назад

    Great video, would this still work if you set up a local host name for both eg: siteone.test and sitetwo.test using say the macOS host file?

    • @aschmelyun
      @aschmelyun  4 года назад +1

      Unless you're routing them through the same Laravel app using domain routing, unfortunately no. You can use two different domains, but you would also need a different port. E.g. siteone.test and sitetwo.test:81

  • @AliRaza-wq6nh
    @AliRaza-wq6nh 4 года назад +1

    why laravel is slow on MacOs????

    • @aschmelyun
      @aschmelyun  4 года назад +2

      It's not Laravel, it's Docker. Unlike on Linux servers and computers, there's a virtualization layer between the MacOS filesystem and Docker's filesystem, which causes a pretty significant delay.

  • @sreeparnadas2748
    @sreeparnadas2748 2 месяца назад

    I have a confusion,
    If I want to make a dockerized project then I will not install php or laravel im my local machine. I will install everything within docker. But If I want to use php artisan command to create laravel controller, middlewares or laravel tinker features, then what will I do ? It's not possible I will create everything directly in docker container using command line. I need an editor to modify those files.. Then what will I do?
    It'll be helpful if anyone give response. Thank you!

    • @aschmelyun
      @aschmelyun  2 месяца назад

      You should use a volume mount to sync your local directory into the running docker container (you can use the -v option for this).
      Then, run the commands in the Docker container by using `docker exec -it container-id php artisan make:controller` and it'll show up in both the container and your local file system!

    • @sreeparnadas2748
      @sreeparnadas2748 2 месяца назад

      @@aschmelyun Okay. Thank you

  • @JyrkiGrohn
    @JyrkiGrohn 3 года назад

    You don’t need another network inside the docker containers, you can access the other container’s services by using the ip-number of your host computer. Let’s say the ip of host computer is 192.168.1.100, then you can use in app-one’s UserController: $response = Http::get(‘192.168.1.100:8081/users’);

    • @oluwasegunibidokun3910
      @oluwasegunibidokun3910 Год назад

      The behaviour of this approach is not predictable. From Connection Time Out errors to Nginx gateway time out errors.

  • @Tux0xFF
    @Tux0xFF 4 года назад

    good videos on the subject but im having a hard time moving from homestead/vagrant, dockers seems like too much work

  • @PlayGameToday
    @PlayGameToday 4 года назад +1

    And now make this tutorial for Windows! Ahahah

  • @Tux0xFF
    @Tux0xFF 4 года назад

    good info but still, homestead/vagrant seems a better solution for me

  • @thecasualgamer90
    @thecasualgamer90 Год назад

    Instead of 2 docker compose, you can use One docker compose file to run multiple Laravel.
    Just 2 php sections, 1 MySQL section and 1 Phpmyadmin section. That's it. One Compose file can run 10+ Laravels.