I'm trying to configure fig
so that I can connect to my database server without specifying a fully qualified domain name. The database is running on bare metal (not in docker). On the host, glinda.local
is specified in /etc/hosts
and I'd like the container to mimic this behavior (though not rely on the host's config).
I found this suggestion on github, but it fails since /etc/hosts
is on a read-only file system.
So the question remains, how can I add glinda.local
from fig.yml
to /etc/hosts
inside my docker container?
From Docker v1.3.1 (I think) you have available the option --add-host
in docker run
. Unfortunately this options has not been merged to fig:master yet, but there is a PR with it. When merged (or using that branch) you should be able to use it in this way:
extra_hosts
Add hostname mappings. Use the same values as the docker client --add-hosts parameter.
> extra_hosts:
> - docker: 162.242.195.82
> - fig: 50.31.209.229
An entry with the ip address and hostname will be created in /etc/hosts inside containers for this service, e.g:
> 162.242.195.82 docker
> 50.31.209.229 fig