当前位置:   首页安装配置

搭建文件:基于docker搭建nginx文件主机的方法步骤

发布日期:2021-07-12 10:18 | 文章来源:源码中国

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

说明:

  • 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文件主机 的资料请关注本站其它相关文章!

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部