server { listen 7070; server_name localhost; charset utf-8; location /files { #在docker内Nginx的目录 alias /home/files; expires 1d; allow all; autoindex on; }
2.启动命令
docker run --name Nginx -d -p 7070:7070 -v D:\dev\Nginx-1.13.6\conf\docker_Nginx.conf:/etc/Nginx/Nginx.conf -v D:\tools\files:/home/files Nginx
说明:
- D:\dev\Nginx-1.13.6\conf\docker_Nginx.con是我本机配置文件的地址
- /etc/Nginx/Nginx.conf是docker Nginx内的配置文件地址
- D:\tools\files是我本地要共享文件夹的地址
- /home/files是在docker Nginx内映射的地址
3.结果
访问localhost:7070/files可以看到最终映射的文件。
执行命令docker exec -it Nginx bash可以进入docker Nginx内部,结果如下
λ docker exec -it Nginx bash root@178a892f73ce:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@178a892f73ce:/# cd home/ root@178a892f73ce:/home# ls files root@178a892f73ce:/home# cd files/ root@178a892f73ce:/home/files# ls 2018-08-09 2018-08-13 2018-09-04 root@178a892f73ce:/home/files# exit exit
以上就是基于docker搭建Nginx文件服务器的方法步骤的详细内容,更多关于docker搭建Nginx文件服务器 的资料请关注编程之家其它相关文章!