1.在本机新建配置文件docker_nginx.conf
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
说明:
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文件服务器 的资料请关注亿速云其它相关文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。