How can I setup a domain domain.tld forward to a specific docker container listening on a specific port i.e. port 2375 (with a lamp config inside)? The server I'm using is Ubuntu 14.04 and the server management software is Webmin 1.700.
-
possible duplicate of [How to use DNS/Hostnames or Other ways to resolve to a specific IP:Port](http://serverfault.com/questions/74362/how-to-use-dns-hostnames-or-other-ways-to-resolve-to-a-specific-ipport) – kasperd Aug 23 '14 at 09:15
2 Answers
dns doesn't know anything about ports or routing.. its just to convert a hostname into an ip. You can't say send traffic to http://domain.com
to http://1.2.3.4:4531/
Docker isn't a dump in easy solution you need some smarts around it to make the magic happen
- 21,910
- 7
- 55
- 79
-
Where do you think I can proceed? Is iptables the right direction? I'm not building a production evironment, it's just to understand the implementation logic around docker. – Viktor Dick Aug 21 '14 at 13:18
The most you can do with DNS is point the IP to your docker host. The port redirection has to happen elsewhere. There are multiple ways to do that depending on your needs. Here are a couple.
1) Use docker run -p 80:2375 ...
to map port 80 on the docker host to port 2375 on the container. This is the simplest solution but requires that nothing else will need to listen on port 80.
2) Run a proxy such as nginx on the host or in a container (again using -p or -P) to redirect traffic to your application. It's a more complicated solution but one that will work if you need to send port 80 to multiple applications on the same docker host.
- 1,346
- 1
- 9
- 4
-
Thanks, I see #2 of your answer is what I'm look for. I'm already following an Apache mod_proxy solution. In fact there are different apps listening on port 80, all of them already on the host. The general idea is to have some side projects enclosed in containers for easier deployment. – Viktor Dick Aug 22 '14 at 16:12