Let a simple php script run inside a docker container with docker-compose – everything on a subdomain with existing nginx reverse proxy by jwilder

what I have:

what I need:
run a small php application on a subdomain

I am new to docker, nginx etc so this question might seem a little stupid to you but after hours of research I could not find anything that actually answers my fundamental questions:

–> How can I host a simple php file with a new docker container making use of the existing nginx proxy container and without changing the nginx container.

My docker-compose so far:

version: '2'

    image: php:fpm
      - "9090:80"
      - VIRTUAL_HOST=subdomain.xxx.tld
      - VIRTUAL_PROTO=fastcgi
      - VIRTUAL_PORT=9090
      - VIRTUAL_ROOT=/var/www/html
      - VIRTUAL_NETWORK=nginx-proxy
      - LETSENCRYPT_HOST=subdomain.xxx.tld
      - /srv/www/production/subdomain.xxx.tld:/var/www/html

So my questions are:

  • Do I have to name the ports? 9090 seemed to be free
  • inside the /srv/www/production/subdomain.xxx.tld lies a simple index.php file. Do I have to call it or does calling the / url already call the index.php?
  • what image should I use?
  • Is making use of the VIRTUAL_HOST variable enough to actually create a working subdomain? Of course I have registered a CNAME inside my providers dns settings.

There is no error the container is not really starting this way so I guess the docker-compose.yml is not yet correct

Thank you

Source: Docker Questions