Skip to content

NOTE20210722

Somkiat Puisungnoen edited this page Jul 22, 2021 · 5 revisions

Note from 2021/07/22

Workshop NodeJS + Nginx

docker image build -t demo-nodejs ./nodejs
docker image build -t demo-nginx ./nginx
docker network create web_workshop
docker container run -d --name mynodejs --net web_workshop demo-nodejs
docker container run -d --name nginx --net web_workshop -p 8888:8080 demo-nginx
curl localhost:8888
Hello World in hostname=e6d545646c5a

Working with Network alias

docker container run -d --net web_workshop --net-alias mynodejs demo-nodejs
docker container run -d --net web_workshop --net-alias mynodejs demo-nodejs

docker container run -d --name nginx --net web_workshop -p 8888:8080 demo-nginx
curl localhost:8888

docker container run --rm --net web_workshop alpine nslookup mynodejs

Working with Docker compose

File docker-compose.yml

version: "3.9"
services:
    nginx:
        build: 
            context: ./nginx
            dockerfile: Dockerfile
        ports:
          - 8888:8080

    mynodejs:
        build: 
            context: ./nodejs
            dockerfile: Dockerfile

Run

$docker-compose build
$docker-compose up -d --scale mynodejs=5
$docker-compose ps
$docker-compose logs --follow
$docker-compose down
Clone this wiki locally