Docker:部署Nginx

目录


一、搜索镜像

linux 复制代码
docker search docker-0.unsee.tech/nginx:1.14.2

二、拉取镜像

linux 复制代码
docker pull nginx:1.14.2

三、创建本地挂载目录

linux 复制代码
mkdir -p /root/nginx/{conf,html,log} 

四、编写nginx配置文件

需要注意的是,这里的root目录一定要写/usr/share/nginx/html否则找不到

conf 复制代码
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  192.168.98.129;
		charset utf-8;

		location / {
			root   /usr/share/nginx/html;
            index  index.html index.htm;

			try_files $uri $uri/ /index.html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

五、启动容器

linux 复制代码
docker run -d --name nginx -p 80:80 \
--restart=unless-stopped \
-v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/nginx/html:/usr/share/nginx/html \
-v /root/nginx/log:/var/log/nginx \
--network 网络名称 \
nginx:1.14.2
相关推荐
❀͜͡傀儡师21 小时前
docker安装mac系统
macos·docker·容器
TH_11 天前
腾讯云-(8)-宝塔面板-安装Docker
docker·云计算·腾讯云
RUNNING123!1 天前
RedHat 7.9 docker 安装 zabbix
docker·容器·zabbix
香吧香1 天前
docker网络总结
docker
weixin_449290011 天前
docker_ollama
docker·容器·eureka
weixin_537765801 天前
【容器技术】虚拟化原理与Docker详解
运维·docker·容器
-dcr1 天前
41.docker完整版
docker
胡斌附体1 天前
docker健康检查使用
运维·docker·依赖·健康检查
火车头-1101 天前
【docker 部署nacos1.4.7】
运维·docker·容器
j200103221 天前
Docker 部署与管理
docker·容器·eureka