---
# System prepended metadata

title: Docker
tags: [林展]

---

# Docker
1.vpc
2.ec2
3.ssh
4.docker
5.start(systemctl start docker)
6.touch docker
7.wget (執行程式)
8.nano dockerfile
chmod +x server
9.docker build -t "server".
10.docker run -d -p 8080:80 server
11.docker run -d -p 8081:80 server
12.security 開8080 8081 in bound
測試10.11.
13.amazon-linux-extras install nginx1
14.nano /etc/nginx/nginx.conf
15.upsteam:
外面upstream name{
least_conn;
server 127.0.0.1:8080;
server 127.0.0.1:8081;
}
裡面location / {
proxy_pass http://name;
} 

### dockerfile
FROM amazonlinux:2
COPY . .
RUN yum update -y
CMD ./server
EXPOSE 80
### 補充
docker ps(查看docker狀態)
放檔案在/usr/share/nginx/html在查詢http://ip/檔案名稱
userdata 要先把mginx.conf刪掉再wget
### userdata
#!/bin/bash
cd /home/ec2-user
yum install docker -y
systemctl start docker
wget sever網址
wget dockerfile 網址
chmod +x server
docker build -t "server" .
docker run -d -p 8080:80 server
docker run -d -p 8081:80 server
amazon-linux-extras install nginx1 -y
cd /etc/nginx
rm -rf nginx.conf
wget nginx.conf網址
systemctl restart nginx
###### tags: `林展`
