How to hide Docker containers behind a single hostname

I’m pretty new to Docker. I started by approaching with the VM mindset, but I’m realizing that it uses a whole different paradigm from VMs, or even traditional LXC containers.

The biggest challenge has been with understanding how networking works. I’m trying to use Docker to run multiple services on a machine that require some of the same ports, to avoid port conflicts.

  • Send “sigterm” from Java to Bash script
  • docker command is showing nothing in centos7
  • node js os.networkInterfaces() not returning any results when called through docker entrypoint on AWS
  • Deploying with docker push is slow because there are many images
  • “CMD ['/home/user/']” in docker file doesn't work with docker-compose
  • connect robomongo to mongo instance running inside docker container
  • I want to access all of them using the FQDN of the host machine, without having to worry about adding the container FQDNs to DNS. I’m forwarding the relevant container ports to unused host ports.

    The problem is that, when I try to access the services from my browser, it’s redirected to the FQDN of the container, which it can’t resolve. The result is a “Server not found” error.

    Is there a way to hide all the containers behind the host’s FQDN, without ever having to resolve the containers’ FQDNs?

  • Access host database from a docker container
  • MupX, graphicsmagick and env var
  • Docker Swarm DNS on custom network?
  • is there a way to do bind particular port on host to container port using docker file
  • How to install Docker on offline Windows 7 machine
  • External static IP with Docker
  • One Solution collect form web for “How to hide Docker containers behind a single hostname”

    You can make each docker container use a different outside port and then have a server docker with something like nginx or apache that reverse proxies the requests. I had to build something like this that takes everything in at one hostname and then passes through all the traffic to the appropriate container and port.

    The difficulty is docker containers having new addresses each time they’re created. You can dynamically figure out their addresses when they start up and have the proxy container start last with those addresses. The way you can grab those addresses is with a ‘docker inspect’ and awk the data you want, or you can use one of these libraries like docker-py to grab the relevant data.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.