Methods and steps to build nginx file server based on docker

Methods and steps to build nginx file server based on docker

1. Create a new configuration file docker_nginx.conf on this machine

server {
  listen 7070;
  server_name localhost;
  charset utf-8;

  location /files {
    #In docker, nginx's directory alias /home/files;
    expires 1d;
    allow all;
    autoindex on;
  }

2. Start the command

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

illustrate:

  • D:\dev\nginx-1.13.6\conf\docker_nginx.con is the address of my local configuration file
  • /etc/nginx/nginx.conf is the configuration file address in docker nginx
  • D:\tools\files is the address of the local folder I want to share
  • /home/files is the address mapped in docker nginx

3. Results

Visit localhost:7070/files to see the final mapped files.

Execute the command docker exec -it nginx bash to enter docker nginx. The result is as follows

λ 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

The above is the detailed content of the method and steps for building an nginx file server based on docker. For more information about building an nginx file server with docker, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Graphic tutorial on configuring nginx file server in windows 10 system
  • Nginx learning static file server configuration method
  • Detailed explanation of nginx configuration static file server
  • Detailed process of using nginx to build a webdav file server in Ubuntu

<<:  JavaScript canvas to achieve mirror image effect

>>:  Several ways to backup MySql database

Recommend

Implementation of Docker to build private warehouse (registry and Harbor)

As more and more Docker images are used, there ne...

SpringBoot integrates Activiti7 implementation code

After the official release of Activiti7, it has f...

Apache Log4j2 reports a nuclear-level vulnerability and a quick fix

Apache Log4j2 reported a nuclear-level vulnerabil...

js native carousel plug-in production

This article shares the specific code for the js ...

Example code for converting html table data to Json format

The javascript function for converting <table&g...

How to solve the problem of clicking tomcat9.exe crashing

A reader contacted me and asked why there were pr...

How to deploy Spring Boot using Docker

The development of Docker technology provides a m...

js to achieve 3D carousel effect

This article shares the specific code for impleme...

Solution to the Docker container being unable to access the host port

I recently encountered a problem at work. The doc...

Detailed explanation of fetch network request encapsulation example

export default ({ url, method = 'GET', da...

Webservice remote debugging and timeout operation principle analysis

WebService Remote Debugging In .NET, the remote d...

Detailed explanation of the use of umask under Linux

I recently started learning Linux. After reading ...

Detailed explanation of the use of base tag in HTML

In requireJS, there is a property called baseURL....