1

For the company I work at, I setup a docker environment using docker-composer and multiple containers so we can all benefit from having the same environment. I created a subdomain DNS record (dev.company.com) pointing to 127.0.0.1. This works fine for reaching projects from within the browser to the appropriate Apache vhosts. The problem however is that we cannot resolve this domain within the PHP container because the DNS points towards 127.0.0.1 how can I add a custom entry to the docker php container to resolve *.dev.company.com to the Apache container?

Also adding this to /etc/hosts is not really an option because we run like 50+ projects.

I found some solutions online which just said to add php to the same container, but this kinda defeats the purpose of having separate containers per service. Added docker-composer file as reference.

Note: I'm the only one using Linux in the office other colleagues are using Docker on Windows or Mac, so a Linux only solution won't cut it :)

version: "3.7"
services:
    php:
        build: php
        env_file:
            - ./conf/php.config.env
        volumes:
            - ./htdocs:/htdocs
        expose:
            - "9000"
        links:
            - mysql
            - mssql
            - mail
        restart: always
        init: true
    apache:
        build: apache
        volumes:
            - ./htdocs:/htdocs:ro
        ports:
            - "80:80"
            - "443:443"
        links:
            - php
        restart: always
        init: true
    mysql:
        build: mysql
        env_file:
            - ./conf/mysql.config.env
        volumes:
            - ./mysql/data:/var/lib/mysql
        ports:
            - "3306:3306"
        restart: always
    mssql:
        image: microsoft/mssql-server-linux
        env_file:
            - ./conf/mssql.config.env
        volumes:
            - ./mssql/data:/var/opt/mssql/data
        ports:
            - "1433:1433"
        restart: always
    mail:
        image: schickling/mailcatcher
        ports:
            - "1080:1080"
        restart: always
        init: true
    redis:
        image: redis
        expose:
            - "6379"
        links:
            - php
        restart: always
        init: true
WhiteFang
  • 199
  • 1
  • 10

0 Answers0