title: Accessing Docker from host network using domain name
body: <p>hey guys I have a docker container A with a domain name attached to it on a host B with a domain name attached to it as well.....how can I access the said container A via A's domain name rather than an B's ip address or domain name from computer C on the host B's local network.</p>
  
  <p>thus <code>C -&gt; A( via wwww.cname.url)</code> rather than <code>C -&gt; B( www.bname.url:port) -&gt; A</code></p>
  
  <p>E.G.</p>
  
  <p>the following is a docker-compose with services</p>
  
  <pre><code>version: "3.2"
  services:
    php:
      links:
        - mysql
      image: arm32v6/php:7.1.24-fpm-alpine3.8-lavalite
      networks:
        - backend
      working_dir: /var/www/html
      volumes:
        - ./website/:/var/www/html/
      privileged: true
    node:
      domainname: docker.local
      hostname: node
      networks:
        frontend:
          aliases:
            - node.docker.local
      links:
        - "apache:dev.docker.local"
      depends_on:
        - apache
      image: arm32v7/node:latest
      entrypoint: yarn
      command: twill-dev
      volumes:
        - ./website:/usr/src/app
      working_dir: /usr/src/app
      ports:
        - "3000:3000"
        - "3001:3001"
    apache:
      domainname: docker.local
      hostname: dev
      image: arm32v7/httpd:2.4
      depends_on:
        - php
        - mysql
      networks:
        frontend:
          aliases:
            - apache
            - dev.docker.local
        backend:
          aliases:
            - apache
      privileged: true
      ports:
        - "8880:80"
      working_dir: /var/www/html
      volumes:
        - ./website/:/var/www/html/
        - ./httpd.conf:/usr/local/apache2/conf/httpd.conf
        - ./fpm.conf:/usr/local/apache2/conf/extra/httpd-vhosts.conf
    mysql:
      image: yobasystems/alpine-mariadb:arm32v7
      volumes:
        - ./datadir:/var/lib/mysql
      networks:
        - backend
      environment:
        - MYSQL_VERSION=5.7
        - MYSQL_ROOT_PASSWORD=rootpassword
        - MYSQL_USER=test
        - MYSQL_PASSWORD=testpass
        - MYSQL_DATABASE=test_db
  networks:
    frontend:
      external:
        name: localnet
    backend:
  </code></pre>
  
  <p>I want to be able to access service <strong>apache</strong> by its domain name set to <em>dev.docker.local</em> the ip of which is on a network 17.18.0.1/24</p>
  
  <p>The host has an IP which is on a network 192.168.1.0/24 with a domain name dev.server.local</p>
  
  <p>I have a dev pc on the network 192.168.1.0/24 and it can access the service containers via the hosts IP and usually a port exposed for the particular service.</p>
  
  <p><strong>UPDATE</strong>
  The host can be reached at server.local from outside the network
  my network interface has the following entries</p>
  
  <pre><code>dns-search server.local
  dns-domain server.local
  </code></pre>
  
  <p>the docker container has the following</p>
  
  <p>hostname nginx
  domainname server.local</p>
  
  <p>do I need to also edit a host file or resolv.conf file?</p>
  
  <p>It seems the host is running avahi service discovery. Would this affect anything?</p>
  
  <p>So can I </p>
  
  <ul>
  <li>set an internal domain set to the host and have docker containers on subdomains? How would outside devices access this via the domain?</li>
  <li>attach the docker container to be on the host's network thus having an ip in the 192.168.1.0/24 and being able to be pinged by devices on that network as well. Will the domain resolve to it?</li>
  <li>Is there a dynamic DNS software I can  use that can hook this up to me so that its not a manual process. Thus it will detect the server and route incoming requests to it via the domain name?</li>
  </ul>