2

Currently, I have two containers php-fpm and NGINX where I run the PHP application.

Now my question, is there a way to "connect" two docker containers without using a volume? Both containers need my application (NGINX to send static files e.g. css/js and php-fpm to interpret the PHP files).

Currently, my application is cloned from git into my NGINX container and I had a volume so the php-fpm also had the files to interpret PHP. I search for a solution without that my application is on the host system.

Aram Grigoryan
  • 740
  • 1
  • 6
  • 24
False
  • 61
  • 8

1 Answers1

-1

Am, not sure what you trying to archive. But my docker-compose.yml is look lite this:

    php:
      container_name: custom_php
      build:
        context: php-fpm
      args:
        TIMEZONE: 'UTC'
      volumes:
        - ./website:/var/www/symfony
      networks:
        - app_net

    nginx:
      build: nginx
      container_name: custom_nginx
      ports:
        - 80:80
      volumes:
        - ./website:/var/www/symfony
      networks:
        - app_net

    networks:
      app_net:
        driver: bridge

Just make sure they are in one network and then you can talk from container to container by container name and port. Hope that helps

Alex
  • 49
  • 6
  • With this solution i also have a volume and the application on the host system. I want a solution that the application is in the nginx container and the php-fpm can read the files from the nginx container. – False Jun 26 '18 at 12:00
  • create volume and share one volume between them than. Look at answer https://stackoverflow.com/questions/44284484/docker-compose-share-named-volume-between-multiple-containers – Alex Jun 26 '18 at 12:03
  • Alex its that what i dont want -> a volume! – False Jun 27 '18 at 10:39