B
B
bio2017-04-07 15:17:06
Docker
bio, 2017-04-07 15:17:06

How to reach nginx from php container?

Hello.
The nginx container has port 8000 open to 80. The site on the host opens at localhost:8000
The php container has no public ports.
It is necessary to make sure that php can reach nginx at the host address (localhost:8000).
How to do it ?
Config example:

version: "2"

services:

  nginx:
    build: nginx
    container_name: project_nginx
    volumes:
      - ../:/var/www/project
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/project.conf:/etc/nginx/vhosts.d/project.conf
    ports:
      - "8000:80"
    restart: always
    depends_on:
      - php

  php:
    build:
      context: ./php
      args:
        HOST_USER_UID: ${HOST_USER_UID}
        HOST_USER_GID: ${HOST_USER_GID}
    container_name: project_php
    volumes:
      - ../:/var/www/project
      - ./php/fpm.conf:/usr/local/etc/php-fpm.d/www.conf:ro
      - ./php/php.ini:/usr/local/etc/php/php.ini:ro
    tty: true
    restart: always

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lxfr, 2017-04-12
@lxfr

It is necessary to make sure that php can reach nginx at the host address (localhost:8000).

You can once again, and in Russian, who should get through to what and why?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question