Docker multiple domains e.g. app1 = app2 =

January 11, 2015 10.8k views

Hello, is it possible to run different containers with different Domains?

For example:
container 1 has an application with port 123456 running
and the container should only reachable on

and container 2 has the same application (with port 123456) but should only reachable with

yours sincerely

1 Answer

You can achieve that by running a reverse proxy server (such as nginx) in front of the applications.

First, install nginx on your droplet that is hosting the containers:

sudo apt-get update
sudo apt-get install nginx

Then, for each application, create a server block:

sudo nano /etc/nginx/sites-available/

and insert the following into the file (replace and 2368 as needed):

server {
    listen 80;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;


Enable the server block:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Once you have done that for all applications, restart nginx:

sudo service nginx restart
  • Is this only for http?
    Do you know a reverse proxy for all protocols and ports?

    Waht i have to do on docker?
    e.g set --ip or hostname?

Have another answer? Share your knowledge.