I am using this lib:
https://github.com/jwilder/nginx-proxy
Here is my docker-compose file:
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local
service1:
image: mynode:1.4
build: .
volumes:
- .:/app
restart: always
environment:
- VIRTUAL_HOST=service1.local
service2:
image: mynodeother:1.3
build: .
volumes:
- .:/app
restart: always
environment:
- VIRTUAL_HOST=service2.local
I added 2 new node services...
I can do like this: curl -H "Host: service2.local" localhost
and get response from service2....
Questions are what benefits I have from this? And how can I run service1 on 80 port?
here is Dockerfile
from service1:
FROM node:6.9.4
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN npm install nodemon -g
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]