From 5c57f8a1a752df7d26a75f4e0338bcd4b3015efd Mon Sep 17 00:00:00 2001 From: cytopia Date: Sat, 28 Apr 2018 16:28:13 +0200 Subject: [PATCH] Fix DNS issues with CNAME's --- docker-compose.yml | 20 +++++++++---- .../communicating-with-external-hosts.rst | 29 +++++++++++++++++-- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 17e434a4..05f0bd64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: # Bind (DNS Server) # ------------------------------------------------------------ bind: - image: cytopia/bind:0.14 + image: cytopia/bind:0.15 restart: always ports: # [local-machine:]local-port:docker-port @@ -80,6 +80,11 @@ services: dns: - 127.0.0.1 + # MacOS and Windows have this by default, this hack also allows it for Linux + extra_hosts: + docker.for.lin.host.internal: 172.16.238.1 + docker.for.lin.localhost: 172.16.238.1 + networks: app_net: ipv4_address: 172.16.238.100 @@ -137,15 +142,18 @@ services: - MYSQL_BACKUP_PASS=${MYSQL_ROOT_PASSWORD} - MYSQL_BACKUP_HOST=mysql + dns: + - 172.16.238.100 + + # MacOS and Windows have this by default, this hack also allows it for Linux + extra_hosts: + docker.for.lin.host.internal: 172.16.238.1 + docker.for.lin.localhost: 172.16.238.1 + networks: app_net: ipv4_address: 172.16.238.10 - dns: - - 172.16.238.100 - - 8.8.8.8 - - 8.8.4.4 - volumes: # ---- Format: ---- # HOST-DIRECTORY : DOCKER-DIRECTORY diff --git a/docs/tutorials/communicating-with-external-hosts.rst b/docs/tutorials/communicating-with-external-hosts.rst index b305a507..2b8c504e 100644 --- a/docs/tutorials/communicating-with-external-hosts.rst +++ b/docs/tutorials/communicating-with-external-hosts.rst @@ -24,8 +24,15 @@ There are two things you need to make sure of are met beforehand: Host IP: Docker on Linux ------------------------ -If you run Docker on Linux the host IP is usually ``172.17.0.1``. +If you run Docker on Linux the host IP is always ``172.16.238.1``, which is the default gateway +IP address within the Devilbox bridge network (see ``docker-compose.yml``). +By default Docker on Linux does not have CNAME's of the host computer as for example with MacOS +or Windows, therefore two custom CNAME's have been added by the Devilbox in order to emulate the +same behaviour: + +* CNAME: ``docker.for.lin.host.internal`` +* CNAME: ``docker.for.lin.localhost`` Host IP: Docker for Mac ----------------------- @@ -96,13 +103,29 @@ Mapping on Linux ^^^^^^^^^^^^^^^^ If you are running Linux as your host operating system you would use the IP address of the host -computer which was identified as ``172.17.0.1``. +computer which was identified as ``172.16.238.1``. .. code-block:: bash :name: .env :caption: .env - EXTRA_HOSTS=mywebserver.loc=172.17.0.1 + EXTRA_HOSTS=mywebserver.loc=172.16.238.1 + +or + +.. code-block:: bash + :name: .env + :caption: .env + + EXTRA_HOSTS=mywebserver.loc=docker.for.lin.host.internal + +or + +.. code-block:: bash + :name: .env + :caption: .env + + EXTRA_HOSTS=mywebserver.loc=docker.for.lin.localhost Mapping on MacOS