ubuntu下nginx代理到个docker(个人笔记,没有参考价值)
程序员文章站
2022-05-20 12:25:49
...
-
主机ubuntu必须是64位
-
首先pull 一个ubuntu
-
docker run -ti ubuntu_image_id
-
在docker里面,执行行应的命令,执行后退出
- docer ps -a
-
docker commit -a 'your name ' -m 'commit info ' ps_name user_name/image_name:tag
-
docker login && docker push
- use docker pull
run script when docer run
- docer run -ti image_id /path/script.sh
- do someting
- exit
- docker ps -a
- docker start container_id
nginx 配置
server { listen 80; listen [::]:80; server_name name.test.com; location / { proxy_pass http://127.0.0.1:port1; proxy_set_header Hos name.test.com; proxy_set_header X-Forwarded-For $remote_addr; } } server { listen 80; listen [::]:80; server_name age.test.com; location / { proxy_pass http://127.0.0.1:port2; proxy_set_header Hos age.test.com; proxy_set_header X-Forwarded-For $remote_addr; } }
这样就可以将请求转发到不同的docker里面了。
此时docker的启动命令 docker run -ti -p port1:80 -name name.test.com image_id /path/script.sh
下次启动时,直接docker run name.test.com
上一篇: Nginx负载均衡的配置