侧边栏壁纸
  • 累计撰写 42 篇文章
  • 累计创建 82 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

Docker安装Nginx

Even
2022-09-02 / 0 评论 / 0 点赞 / 443 阅读 / 195 字 / 正在检测是否收录...

Docker安装Nginx

创建本地文件夹

mkdir -p /root/nginx/www /root/nginx/logs /root/nginx/conf

创建容器

docker run -p 80:80 --name nginx \
-v ~/nginx/html:/usr/share/nginx/html \
-v ~/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v ~/nginx/conf.d:/etc/nginx/conf.d \
-v ~/nginx/logs:/var/log/nginx \
-d nginx

复制Nginx配置

docker cp nginx:/etc/nginx/nginx.conf /root/nginx/conf

在本机www目录下创建index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>docker搭建nginx</title>
</head>
<body>
    <h1>docker搭建nginx映射成功</h1>
    <p>test</p>
</body>
</html>

Docker-compose.yaml

version: "3.9"
    
services:
  web:
    image: nginx
    container_name: nginx
    restart: always
    ports: 
    	- 80:80
    volumes:
      - /usr/local/docker/mysql/conf:/etc/mysql
      - /usr/local/docker/mysql/logs:/var/log/mysql
      - /usr/local/docker/mysql/data:/var/lib/mysql
    
0

评论区