Assign a domain name to a container

I am looking for a way to assign a domain name to a container when it starts. For example, I want to start a web server container and have access to web pages through a domain name. Is there an easy way to do this?

+6
source share
1 answer

As far as I know, Docker does not provide this function out of the box. But, of course, there are several workarounds here. In fact, you need to deploy DNS on your host, which will distinguish between containers and resolve domain names in dynamic IP addresses. So you can try:

  • Deploy some DNS solutions that support Docker (I suggest you use SkyDNSv1 / SkyDock );
  • Configure your host to work with this DNS (by default, SkyDNS makes containers know each other by name, but the host does not know about it);
  • Launch your containers with an explicit --hostname (you will probably use the container_name.image_name.dev.skydns.local schema).

You can skip step # 2 and launch the browser inside the container: it will detect the web application container by host name.

+1
source

Source: https://habr.com/ru/post/988956/


All Articles