Setup subdomains in docker environment

I am running different services in Docker Containers on my Ubuntu server (14.04 Trusty Tahr) at home. My currently Setup at the moment is as following:

  • Jenkins jenkins.slarti
  • Gitlab and under gitlab.slarti
  • Java Servlet Webserver under servlet.slarti (apache tomcat)
  • “Normal” Webserver under web.slarti (nginx)

These domains are virtualhost’s and I have already setup an nginx proxy.

  • Docker - decrease pull size
  • Docker: connect EHOSTUNREACH when I connect to mongo container
  • bcrypt fails to install inside docker
  • on osx, docker run -v $(pwd):… does not get expanded
  • Docker - /bin/sh: <file> not found - bad ELF interpreter - how to add 32bit lib support to a docker image
  • Writing to docker volume from Dockerfile does not work
  • Nginx-proxy docker run:

    docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy

    Jenkins docker run:

    docker run -d --name jenkinsci --expose 8080 -e VIRTUAL_HOST=jenkins.slarti -e VIRTUAL_PORT=8080 jenkins

    Normal Webserver docker run:

    sudo docker run --name nginx1 -P -d --expose 80 -e VIRTUAL_HOST=web.slarti nginx

    Gitlab & docker run:

    docker run -d  --link kanban_redis:kanban_redis -p 80:80 -e KANBAN_SERVER_HOSTNAME="http://localhost"  -e KANBAN_GITLAB_URL=""  -e  KANBAN_REDIS_ADDR="kanban_redis:6379" --expose 80 -e VIRTUAL_HOST=gitlab.slarti leanlabs/kanban:1.4.0

    Apache Tomcat docker run:

    docker run -it --rm -p 8888:8090 -e VIRTUAL_HOST=servlet.slarti tomcat:8.0

    I did the setup according to this guide

    Currently I can’t ping web.slarti, servlet.slarti etc. Neither can i reach these domains if i type their url in the browser.

    I can reach Apache Tomcat via slarti:8888 but I want to reach it through servlet.slarti and that fails since i don’t have a DNS setup.

    What do I have to do to reach the subdomains web.slarti, servlet.slarti etc? How do I setup the reverse proxy correctly so I can reach the domains? And how do I have to configure the DNS?

  • Copy war file from local machine to docker
  • Connection was reset on a flask web app
  • Building docker images from a source directory using different dockerfiles
  • Supertest in Cucumber delay
  • Recommended way to mimic a production server with Docker
  • start multiple docker containers with a single command line shell script (without docker-compose)
  • One Solution collect form web for “Setup subdomains in docker environment”

    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).

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