Docker Community Forums

Share and learn in the Docker community.

How to configure the domain name inside the docker, and how to access the inside application using domain name.. using UBUNTU

i created the docker on alibaba instance, and deployed one camera application(node js).
running the docker using port number 49169, container id “e5ade0aeXXXX”.
The application inside is running with port number “3335”

for that inside of the docker etc/nginix/sites.available/filename , i have created the domain configuration in the file like this…


listen 80;
listen [::]:80;
#root /var/www/poc/axis;
#index index.html index.htm;

return 301 https://$server_name$request_uri;


server {

SSL configuration


listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/b05e7f94f7c0edfget.crt;
ssl_certificate_key /etc/nginx/ssl/generated-private-key.key;

location / {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";


Here how to access the application with "Domain Name???" with this I am not able to access the application inside of the docker

The nginx directive server_name listens for traffic comming in using that domain. It is not responsible magicaly make a valid dns entry available somewhere in the word.

You still need to configure your dns server to resolve the hostname to the ip of your docker host or a loadbalancer that forwards the traffic to your docker host. Though, this has nothing todo with docker. The same applies if nginx is installed as a package on the host os.

Hi Metin thanks for your replay…

Here i would like to share few points with you
1.I have properly configured the dns entry of the domain name(domain) in the dns server
2.I have pinged that domain name in my host machine that sucessful maped with the ip address of my VM
3.Iam able to accessing the docker through the ip:49169 However iam not able to accessing with the domain name
4.Even If i tried to access the inside of the application in docker using ip:3335 it is not responding.

Do ou mind sharing your docker-compose.yml? It gets easier to understand if the full picture is present

actually we did’nt create the compose file we have created the docker using Dockerfile here are the full details for your understanding …

FROM node:10
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ “node”, “server.js” ]

1.docker build -t scriptdocker2 .
2.docker run --name scriptdocker2 -p 49161:8080 -d scriptdocker2

Image details
root@iZa2dah25ebv5oyyngcphtZ:~# docker images
scriptdocker2 latest ac8245f0897e 25 hours ago 907MB

Container Details -
root@iZa2dah25ebv5oyyngcphtZ:~# docker ps
e5ade0ae092a scriptdocker2 “docker-entrypoint.s…” 25 hours ago Up 25 hours 8080/tcp,>80/tcp scriptdocker2

  1. We have deployed nodeJs application in the the container
    2a. when we start the application, it runs with the port of user define, we have assign port - 3335 (We have enabled all the ports in the SG(security group))
    2b. now nodeJs application is running on 3335

  2. To access this application through the web browser we have configured that in the following path
    in docker - /etc/nginx/site-available/default

In default file we are given following

server {

SSL configuration

server_name;// domain name which we need to access from the browser

listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/b05e7f94f7c0e3f0.crt;
ssl_certificate_key /etc/nginx/ssl/generated-private-key.key;

location / {
    proxy_pass;    // re-directing local host to server_name - so that we can able to access that application through web browser
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";


  1. To access the docker we are using (here is public IP and 49169 is docker container running port)


  1. Need to access the nodeJs application with the domain name
    What we tried - 1. Added A record (PFA)
  2. Added in the Docker nginx configuration in default file

It doesn’t worked out for us, can you please suggest how to access the application through the browser which is running the docker
3. How to access the docker application’s which are running in it provided by user defined ports (similar to above cases if i need to run some another application rather than nodeJs)

So nginx is running in a container? If this is so, you will want to create a custom network and start both containers in the same custom network. You only need to publish the port for the nginx container, as nginx will be able to use the custom network to directly communicate with the service on port 3335. would be only valid, if nginx is running inside the same(!) container If its a different container, you will need to use the containername or the network alias instead. Your security group needs to allow incomming traffic for the published port of the nginx container.

One more thing: please start using docker-compose.yml right away. Things will be repeatable, self documented, easier to understand and you can version the files on a git server.

Thanks for you your inputs @meyay Metin still iam working on it …