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

Building a KVM virtualization platform on CentOS7 (three ways)

KVM stands for Kernel-based Virtual Machine, whic...

Zabbix's psk encryption combined with zabbix_get value

Since Zabbix version 3.0, it has supported encryp...

Vue implements dynamic query rule generation component

1. Dynamic query rules The dynamic query rules ar...

Brief analysis of MySQL union and union all

In the database, both UNION and UNION ALL keyword...

Writing High-Quality Code Web Front-End Development Practice Book Excerpts

(P4) Web standards are composed of a series of sta...

Docker installation and configuration steps for MySQL

Table of contents Preface environment Install Cre...

JavaScript timer to achieve limited time flash sale function

This article shares the specific code of JavaScri...

A brief discussion on whether CSS animation will be blocked by JS

The animation part of CSS will be blocked by JS, ...

Solution to the problem that Navicat cannot remotely connect to MySql server

The solution to the problem that Navicat cannot r...

How to install MySQL server community version MySQL 5.7.22 winx64 in win10

Download: http://dev.mysql.com/downloads/mysql/ U...

Batch replace part of the data of a field in Mysql (recommended)

Batch replace part of the data of a field in MYSQ...

JavaScript immediate execution function usage analysis

We know that in general, a function must be calle...

Detailed explanation of MySQL master-slave replication process

1. What is master-slave replication? The DDL and ...

How to solve the problem of margin overlap

1. First, you need to know what will trigger the v...