Open shimguh opened 9 months ago
https://www.nginx.com/resources/glossary/load-balancing/
docker rm,rmi
$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE $ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
docker run -p : 포트번호
$ docker run -itd -p 8001:80 --name lb nginx:latest $ docker run -itd -p 8002:80 --name serv-a nginx $ docker run -itd -p 8003:80 --name serv-b nginx
config
$ cat config/default.conf upstream serv { server serv-a:80; server serv-b:80; } server { listen 80; location / { proxy_pass http://serv; } }
/etc/nginx/conf.d/default.conf 에 복사 https://hub.docker.com/_/nginx
$ sudo docker exec -it lb bash $ pwd /etc/nginx/conf.d
$ sudo docker cp config/default.conf lb:/etc/nginx/conf.d/default.conf
5. index.html 생성
$ tree . ├── README.md ├── lb │ └── config │ └── default.conf ├── serv-a │ └── index.html └── serv-b └── index.html $ cat serv-a/index.html
$ sudo docker cp serv-a/index.html serv-a:/usr/share/nginx/html/index.html Successfully copied 2.05kB to serv-a:/usr/share/nginx/html/index.html $ sudo docker cp serv-b/index.html serv-b:/usr/share/nginx/html/index.html Successfully copied 2.05kB to serv-b:/usr/share/nginx/html/index.html
6. lb 재시작 오류
$ sudo docker stop lb $ sudo docker start lb $ sudo docker logs lb ...
https://docs.docker.com/engine/reference/commandline/network/
$ sudo docker exec -it serv-a bash $ apt update;apt install iputils-ping $ apt install telnet
$ docker network ls - bridge 네트워크는 하나의 호스트 컴퓨터 내에서 여러 컨테이너 연결 - host 네트워크는 컨터이너를 호스트 컴퓨터와 동일한 네트워크에서 컨테이너를 돌리기 위해서 사용 - overlay 네트워크는 여러 호스트에 분산되어 돌아가는 컨테이너들 간에 네트워킹을 위해서 사용
$ docker network ls $ docker network create
$ sudo docker network inspect ablb $ sudo docker network connect ablb serv-a $ sudo docker network connect ablb serv-b $ sudo docker network connect ablb lb $ sudo docker network inspect ablb
도커에서 $ ping $ ping $ telnet
inspect
https://www.nginx.com/resources/glossary/load-balancing/
docker rm,rmi
docker run -p : 포트번호
config
/etc/nginx/conf.d/default.conf 에 복사 https://hub.docker.com/_/nginx
$ sudo docker cp config/default.conf lb:/etc/nginx/conf.d/default.conf
$ tree . ├── README.md ├── lb │ └── config │ └── default.conf ├── serv-a │ └── index.html └── serv-b └── index.html $ cat serv-a/index.html
A
$ sudo docker cp serv-a/index.html serv-a:/usr/share/nginx/html/index.html Successfully copied 2.05kB to serv-a:/usr/share/nginx/html/index.html $ sudo docker cp serv-b/index.html serv-b:/usr/share/nginx/html/index.html Successfully copied 2.05kB to serv-b:/usr/share/nginx/html/index.html
$ sudo docker stop lb $ sudo docker start lb $ sudo docker logs lb ...
$ sudo docker exec -it serv-a bash $ apt update;apt install iputils-ping $ apt install telnet
$ docker network ls $ docker network create
$ sudo docker network inspect ablb $ sudo docker network connect ablb serv-a $ sudo docker network connect ablb serv-b $ sudo docker network connect ablb lb $ sudo docker network inspect ablb
도커에서 $ ping
$ ping
$ telnet