Answer the question
In order to leave comments, you need to log in
How to give a docker container from a server to a domain address?
The container has been successfully launched on the virtual machine.
dockerfile:
FROM node:latest
WORKDIR /usr/src/app
ARG NODE_ENVn
ENV NODE_ENV $NODE_ENV
COPY package*.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
ENV PORT 5000
EXPOSE $PORT
CMD [ "npm", "start" ]
sudo docker run -d -p 27073:5000 $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
****************** registry.gitlab.com/*******:latest "docker-entrypoint.s…" 9 hours ago Up 9 hours 0.0.0.0:27073->5000/tcp, :::27073->5000/tcp
504 Gateway Time-out
The server didn't respond in time.
curl http://localhost:27073
Answer the question
In order to leave comments, you need to log in
The domain is bound not to the container, but to the ip address.
You did not specify exactly where this virtual machine was raised and for what purpose.
If you have a computer for personal use, then the easiest way is to use nip.io or register the domain and ip address of the virtual machine in the hosts file.
If you rented a virtual machine from some provider and want to make it available to everyone by domain, then you need to buy a domain and specify the ip address of the virtual machine in its settings.
Well, or use the same nip.io if this is a general service for a small circle of people.
UPD:
in order to open different web applications on different domains, you need an http proxy, which, based on the domain specified in the http request, will proxy this request to one or another internal address.
Usually, nginx is installed for this, which itself listens on ports 80 and 443.
All domains are configured so that they lead to the address of this server.
In the nginx config, they describe which application should respond to a specific domain, something like this:
server {
listen 80;
server_name site-1.domain.com;
location / {
proxy_pass http://127.0.0.1:27073;
}
}
server {
listen 80;
server_name site-2.domain.com;
location / {
proxy_pass http://127.0.0.1:12345;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question