2

I've 3 docker containers, php7 nginx and mariadb each are linked up and serve simple wordpress sites.

I'd like to add laravel project to the bunch. It all works great except laravel services that I need to run, e.g. queue listener and scheduler cron. How do you recommend dealing with these?

1 Answers1

1

You might want to consider using Docker Compose to orchestrate multiple containers together. For example, you'd have a Docker Compose file that declared a Docker network, and three containers:

  1. Message Queue
  2. Cron Scheduled Tasks
  3. Laravel application + PHP + Web Server

As long as you add each of the containers to the same network, they'll be able to communicate with each other. Another benefit of using Docker Compose is that scaling containers is much easier.

Here's the reference documentation for Docker Compose YAML files: https://docs.docker.com/compose/compose-file/

  • 1
    I use docker-compose, my question was more about structure. Maybe its simpler to have cron and queue service run from the host directly. –  Jun 29 '16 at 18:32
  • 2
    I would advise against running the service on the host directly, otherwise you defeat the purpose of deploying with Docker and you'd have to have a separate deploy for the host machine code. For Laravel specifically, since the code is the same for multiple purposes (queue, scheduler, app) I run a custom start script with a container role via enviroment. Check out this answer for more details https://stackoverflow.com/a/50012509/599230 – Paul Redmond Apr 25 '18 at 00:56