Fix DNS issues with CNAME's

This commit is contained in:
cytopia 2018-04-28 16:28:13 +02:00
parent 8b50316787
commit 5c57f8a1a7
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
2 changed files with 40 additions and 9 deletions

View File

@ -34,7 +34,7 @@ services:
# Bind (DNS Server) # Bind (DNS Server)
# ------------------------------------------------------------ # ------------------------------------------------------------
bind: bind:
image: cytopia/bind:0.14 image: cytopia/bind:0.15
restart: always restart: always
ports: ports:
# [local-machine:]local-port:docker-port # [local-machine:]local-port:docker-port
@ -80,6 +80,11 @@ services:
dns: dns:
- 127.0.0.1 - 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: networks:
app_net: app_net:
ipv4_address: 172.16.238.100 ipv4_address: 172.16.238.100
@ -137,15 +142,18 @@ services:
- MYSQL_BACKUP_PASS=${MYSQL_ROOT_PASSWORD} - MYSQL_BACKUP_PASS=${MYSQL_ROOT_PASSWORD}
- MYSQL_BACKUP_HOST=mysql - 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: networks:
app_net: app_net:
ipv4_address: 172.16.238.10 ipv4_address: 172.16.238.10
dns:
- 172.16.238.100
- 8.8.8.8
- 8.8.4.4
volumes: volumes:
# ---- Format: ---- # ---- Format: ----
# HOST-DIRECTORY : DOCKER-DIRECTORY # HOST-DIRECTORY : DOCKER-DIRECTORY

View File

@ -24,8 +24,15 @@ There are two things you need to make sure of are met beforehand:
Host IP: Docker on Linux 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 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 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 .. code-block:: bash
:name: .env :name: .env
:caption: .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 Mapping on MacOS