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.
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
- 22,748
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,366