読者です 読者をやめる 読者になる 読者になる

docker nginxメモ 【重要】

docker commit srv002 hayase/centos6-nginx:latest
 

f:id:slash67:20151201183726j:plain

 

docker run -i -t -d --name srv002 -p 8081:80 suzuki/centos6-nginx:latest /bin/bash

docker run -i -t -d --name srv002 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
docker run -i -t -d --name srv003 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
 
/etc/init.d/nginx start
chkconfig nginx on
cd /usr/share/nginx/html/
 
 
cd /etc/nginx/conf.d
mv default.conf defaul.conf.org
vim default.conf
 
 
 
4 sudo hostname hoayase
5 hostname
6 exit
7 docker ps
8 docker pull centos:7
9 docker images
10 docker pull centos:6
11 docker run -i -t -d --name srv001 -p 8080:80 centos:6 /bin/bash
12 docker ps
13 docker attach srv001
14 docker ps
15 docker ps -a
16 exit
17 docker attach srv001
18 docker ps
19 docker ps -a
20 docker start srv001
21 docker ps
22 docker ps -a
23 docker start srv001
24 docker start 0fd9bed7ec44
25 docker stop 0fd9bed7ec44
26 docker start 0fd9bed7ec44
27 docker stop 0fd9bed7ec44
28 docker ps -a
29 sudo systemctl restart docker
30 docker ps -a
31 docker stop 0fd9bed7ec44
32 docker start 0fd9bed7ec44
33 docker run -i -t -d --name srv002 -p 8080:80 centos:6 /bin/bash
34 docker attach srv002
35 docekr ps
36 docker images
37 docker commit srv002 hayase/centos6-nginx:latest
38 docker images
39 docker run -i -t -d --name srv002 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
40 docker run -i -t -d --name srv003 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
41 docker ps
42 docker attach srv003
43 docker attach srv001
44 docker attach srv002
45 docker commit srv002 hayase/centos6-nginx-loadbalancer:latest
46 docker run -i -t -d --name loadbalancer001 -p 80:80 hayase/centos6-nginx-loadbalancer:latest /bin/bash
47 docker ps
48 docker attach loadbalancer001
49 docker attach loadbalancer001 4 sudo hostname hoayase
5 hostname
6 exit
7 docker ps
8 docker pull centos:7
9 docker images
10 docker pull centos:6
11 docker run -i -t -d --name srv001 -p 8080:80 centos:6 /bin/bash
12 docker ps
13 docker attach srv001
14 docker ps
15 docker ps -a
16 exit
17 docker attach srv001
18 docker ps
19 docker ps -a
20 docker start srv001
21 docker ps
22 docker ps -a
23 docker start srv001
24 docker start 0fd9bed7ec44
25 docker stop 0fd9bed7ec44
26 docker start 0fd9bed7ec44
27 docker stop 0fd9bed7ec44
28 docker ps -a
29 sudo systemctl restart docker
30 docker ps -a
31 docker stop 0fd9bed7ec44
32 docker start 0fd9bed7ec44
33 docker run -i -t -d --name srv002 -p 8080:80 centos:6 /bin/bash
34 docker attach srv002
35 docekr ps
36 docker images
37 docker commit srv002 hayase/centos6-nginx:latest
38 docker images
39 docker run -i -t -d --name srv002 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
40 docker run -i -t -d --name srv003 -p 8081:80 hayase/centos6-nginx:latest /bin/bash
41 docker ps
42 docker attach srv003
43 docker attach srv001
44 docker attach srv002
45 docker commit srv002 hayase/centos6-nginx-loadbalancer:latest
46 docker run -i -t -d --name loadbalancer001 -p 80:80 hayase/centos6-nginx-loadbalancer:latest /bin/bash
47 docker ps
48 docker attach loadbalancer001
49 docker attach loadbalancer001
 
loadbalancer
1 /etc/init.d.nginx start
2 /etc/init.d/nginx start
3 yum install vim
4 ip a
5 yum install telnet
6 telnet 172.17.0.2 80
7 telnet 172.17.0.3 80
8 telnet 172.17.0.2 80
9 cd /etc/nginx/conf.d
10 mv default.conf defaul.conf.org
12 rm default.conf
11 vim default.conf
 

   upstream web {

       ip_hash;

       server 172.17.0.11;

       server 172.17.0.14;

   }

   server {

       listen 80;

       location / {

           proxy_pass http://web;

       }

   }

ip_hashを消してサーバーを切り替える

srv002 

2 yum install -y epel-release
3 yum install nginx
4 /etc/init.d/nginx start
5 cd /usr/share/nginx/html/
6 vi index.html
7 /etc/init.d/nginx start
8 chkconfig nginx on
9 ip a

 

 core@hoayase ~ $ history
7 docker ps
8 docker pull centos:7
9 docker images
10 docker pull centos:6
11 docker run -i -t -d --name srv001 -p 8080:80 centos:6 /bin/bash
12 docker ps
13 docker attach srv001
14 docker ps
15 docker ps -a
16 exit
17 history

 

ip_hash切り替えられるという確認

core@hoayase ~ $ docker attach srv002

[root@5297665b0e09 html]#

2 yum install -y epel-release
3 yum install nginx
4 /etc/init.d/nginx start
5 cd /usr/share/nginx/html/
6 vi index.html
7 /etc/init.d/nginx start
8 chkconfig nginx on
9 ip a
10*
11 history
12 history
[root@5297665b0e09 html]# core@hoayase ~ $
core@hoayase ~ $
core@hoayase ~ $ docker attach srv003
[root@172cbf0f4608 html]# history
1 /etc/init.d/nginx status
2 /etc/init.d/nginx start
3 chkconfig nginx on
4 cd /usr/share/nginx/html/
5 ls -la
6 vim index.html
7 vi index.html
8 ip a
9 history