Skip to content

Commit

Permalink
Fix DNS issues with CNAME's
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Apr 28, 2018
1 parent 8b50316 commit 5c57f8a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
20 changes: 14 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions docs/tutorials/communicating-with-external-hosts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------
Expand Down Expand Up @@ -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.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=172.17.0.1
EXTRA_HOSTS=mywebserver.loc=docker.for.lin.localhost
Mapping on MacOS
Expand Down

0 comments on commit 5c57f8a

Please sign in to comment.