Curl connection refused between applications on Docker container Curl connection refused between applications on Docker container apache apache

Curl connection refused between applications on Docker container


Instead of adding to extra_hosts of the php-fpm container.Modify the Apache2 container's Backend network definition and add an alias.this was you dont have to keep changing the extra_hosts everytime the ip changes

    networks:        frontend:                      backend:         aliases:          - subdomain.example.app


I figured out what was causing my issue. I needed to add an extra-host to the PHP-FPM section of my docker-compose.yml file. So add:

- "subdomain.example.app:10.0.75.1"

To extra-hosts. Then you need to rebuild your containers:

docker-compose up -d --build apache2 mysql redis

And this is what the PHP-FPM section of your docker-compose.yml for Laradock should look like:

php-fpm:      build:        context: ./php-fpm        args:          - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}          - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE}          - INSTALL_SOAP=${PHP_FPM_INSTALL_SOAP}          - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO}          - INSTALL_ZIP_ARCHIVE=${PHP_FPM_INSTALL_ZIP_ARCHIVE}          - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH}          - INSTALL_PHPREDIS=${PHP_FPM_INSTALL_PHPREDIS}          - INSTALL_MEMCACHED=${PHP_FPM_INSTALL_MEMCACHED}          - INSTALL_OPCACHE=${PHP_FPM_INSTALL_OPCACHE}          - INSTALL_EXIF=${PHP_FPM_INSTALL_EXIF}          - INSTALL_AEROSPIKE_EXTENSION=${PHP_FPM_INSTALL_AEROSPIKE_EXTENSION}          - INSTALL_MYSQLI=true          - INSTALL_TOKENIZER=${PHP_FPM_INSTALL_TOKENIZER}          - INSTALL_INTL=${PHP_FPM_INSTALL_INTL}          - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT}        dockerfile: "Dockerfile-${PHP_VERSION}"      volumes_from:        - applications      volumes:        - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini      expose:        - "9000"      depends_on:        - workspace      extra_hosts:        - "dockerhost:${DOCKER_HOST_IP}"        - "subdomain.example.app:10.0.75.1"      environment:        - PHP_IDE_CONFIG=${PHP_IDE_CONFIG}      networks:        - backend