Docker containers deploy static web pages or web service

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/AinUser/article/details/99095353

First talk about for the scene of this article: My personal blog is originally purchased the domain names will be placed on top of the server github project, do a bit of analytical access

Later, due to github servers in foreign countries, access speed is too slow, and there are just aliyun activities, almost 120 less than a year, so the purchase of a server, ready to move

Generally speaking about the migration process my personal blog, because there are many services on top of the server, so use nginx reverse proxy to achieve, because the server is cheaper, so performance is not very good, so use docker service division, there is only one service personal blog is thrown inside docker

docker installation steps: https://www.runoob.com/docker/docker-container-usage.html

nginx installation steps: https://www.runoob.com/linux/nginx-install-setup.html

nginx reverse proxy is not described in detail, if the main service, then directly in the default configuration file server inside plus a proxy_pass

A plurality of services, use upstream {}

基础用到的命令普及
docker 运行容器命令
docker ps

docker 所有容器命令
docker ps -a

docker 删除容器命令
docker rm 容器id

docker 镜像查看命令
docker images
拉取镜像
docker pull tomcat
启动容器,验证tomcat服务 (命令具体的意思,粘贴到百度就有了)
 docker run -p 8080:8080 tomcat
访问
服务器外网ip:8080即可
如果不行,看是否能ping通或者是aliyun服务器端口是否开放

Here are highlights: static pages and deploy the service

静态页面部署:可以拷贝到docker中tomcat的webapps下,建议挂载
进入docker容器中查看命令,首先,容器得启动
docker exec -it 容器id /bin/bash
进入容器后ls即可查看

挂载静态文件
docker run -d -v /usr/local/tools/ty/servers/blog/:/usr/local/tomcat/webapps/ROOT/ -p 8080:8080 tomcat:latest


服务挂载命令
docker run -d -v /data/demo.war:/usr/local/tomcat/webapps/demo.war -p 8081:8080 tomcat:latest

Above and may differ from yours, some places should need to change it, or else you need to know about the knowledge it can not directly copy

Guess you like

Origin blog.csdn.net/AinUser/article/details/99095353