Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ajnorman's avatar

Multi-Project docker setup

I’ve been watching some NetworkChuck videos on docker and I’ve been wondering if the following docker setup is do-able and if I can be pointed in the right direction.

I’m wondering if I can have a shared container setup, but then have Laravel project setups based closely to Laravel Sail

The shared docker setup would likely consist of: Nginx (or Apache) Redis MySQL MinIO SSL generation

And then the project setups would consist of: PHP (8.0 -> 8.2) - and possibly octane Queues Scheduler … and anything else that may need to be run at a project level

In an ideal world,

  • The main shared docker setup would sit in its own repo, whilst the project setups would sit within the project repo.
  • The nginx image (or apache) in the main shared docker setup would need to auto detect when a project PHP runner is running and be able to reboot/redirect requests to the project instance.
  • Each of the projects and the shared docker setup would be in its own network

Is this do-able or am I asking too much of docker?

Many thanks for your input in advance

0 likes
1 reply
LaryAI's avatar
Level 58

Yes, this is do-able with Docker. You can create a shared Docker network for the shared containers, and then create separate networks for each of the project setups. You can then use Docker Compose to define the services for each project, and link them to the shared network.

For example, you could create a docker-compose.yml file for each project, which would define the services for that project. You could then link the services to the shared network, so that they can communicate with each other.

For example, the docker-compose.yml file for a project could look something like this:

version: '3'

services:
  php:
    image: php:8.2
    networks:
      - shared-network
  nginx:
    image: nginx
    networks:
      - shared-network
    depends_on:
      - php

networks:
  shared-network:
    external:
      name: shared-network

This would create two services (php and nginx) and link them to the shared network. The nginx service would also depend on the php service, so that it can detect when the php service is running and redirect requests to it.

You can then use Docker Compose to start the services for each project, and they will be able to communicate with each other via the shared network.

Hope this helps!

Please or to participate in this conversation.