Error accessing PHP application via Docker

Asked

Viewed 131 times

0

I’m having trouble accessing the application via Docker. I’m getting a "Unable to connect" firefox error when trying to access the localhost:8899 address (ja tentei127.0.0.1:8899 and it also doesn’t work)

I’ve checked the containers via Docker-Compose ps, and they’re all ok. It seems like an error related to mysql, but I’m not sure what it would be exactly.

Details:

  1. Operating System: Ubuntu 18.04
  2. PHP version: 5.6
  3. Framework: Zend Framework 1

Configuration files:

File . env

 DOCKER_HOST_IP=192.168.1.3

Docker-Compose.yml file

version: "3.1"
   services:
     mysql:
     image: mysql:5.7
     container_name: stf-mysql
     working_dir: /application
    volumes:
      - .:/application
     environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=falcom_chamados
    ports:
     - "8901:3306"

    webserver:
       image: nginx:alpine
       container_name: stf-webserver
       working_dir: /application
       volumes:
         - .:/application
         - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
        - "8080:80"

      php-fpm:
        build: phpdocker/php-fpm
        container_name: stf-php-fpm
        working_dir: /application
     environment:
        XDEBUG_CONFIG: "remote_host=${DOCKER_HOST_IP}"
        PHP_IDE_CONFIG: "serverName=falcom-chamados"
     ports:
       - "9019:9000"
     volumes:
       - .:/application
       - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php5/fpm/conf.d                 /99-overrides.ini

The project also has a file called db.php, where you can find some database-related settings

db.php

<?php
   $config = array();

   if (APPLICATION_ENV != 'development') {
      $config['dsn'] = "mysql://root:[email protected]:8901/falcom_chamados";
     } else {
       $config['dsn'] = "mysql://root:[email protected]:8901/falcom_chamados";
   }

     return $config;

1 answer

0

According to the configuration you posted, port 8899 will never answer!

To make it easy, try interpreting the "ports" setting as follows:

ports:
  - "PARA:DE"

That is, the NGINX answers at port 8080, because it is configured as follows:

ports:
  - "8080:80"

If you need Nginx to answer at port 8899, switch to:

ports:
  - "8899:80"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.