Setup subdomains in docker environment

心已入冬 提交于 2019-12-04 15:10:02

I am not expert on networks. But after reading your post, it appears that you do need a DNS config like this:

A -> slarti (or IP)
CNAME jenkins.slarti -> slarti
CNAME gitlab.slarti -> slarti
CNAME servlet.slarti -> slarti
CNAME web.slarti -> slarti

This is what I have done to redirect my subdomains to my Docker containers.

Without proper DNS configuration, your subdomains can't be reached.

With this DNS config, everytime you request gitlab.slarti, you actually reach Nginx, which in turn redirects you to the proper Docker container (if the VIRTUAL_HOST environment variable is configured to gitlab.slarti).

Abhishek
  1. Add an A record for *.example.com for the root IP Address of the machine (Your Ubuntu Server).
  2. Then start binding as much sub domains you want to bind with multiple docker containers those are running different services.

For example:

docker run -d --name jenkinsci --expose 8080 -e VIRTUAL_HOST=jenkins.slarti -e VIRTUAL_PORT=8080 jenkins
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!