Docker completes the implementation of FTP service construction with one line of command

Docker completes the implementation of FTP service construction with one line of command

One line command

docker run -d \
-v /share:/home/vsftpd \
-p 20:20 \
-p 21:21 \
-p 21100-21110:21100-21110 \
-e FTP_USER=zhaoolee \
-e FTP_PASS=eelooahz \
-e PASV_ADDRESS=47.106.108.135 \
-e PASV_MIN_PORT=21100 \
-e PASV_MAX_PORT=21100 \
--name zhaoolee_vsftpd \
--restart=always \
fauria/vsftpd

Parameter explanation:

-d means the new container runs in the background

-v means setting directory mapping. Example: -v /share:/home/vsftpd maps the host's /share directory to the docker container's /home/vsftpd (after user zhaoolee logs in, the program will automatically create a zhaoolee folder in the /home/vsftpd folder to store uploaded files)

-p is the mapping port -p 20:20 means mapping the host port 20 to the docker container's port 20, -p 21:21 means mapping the host port 21 to the docker container's port 21, -p 21100-21110:21100-21110 means mapping the host's ports 21100 to 21110 to the docker container's ports 21100 to 21110

Closely related to the port are two connection modes: active mode and passive mode.

  • Active mode: Port 21 is the default port for FTP, which is the control port of FTP, and port 20 is the data port of FTP. Port 21 is used to receive client connections, and port 20 is used to transmit data. The server (actively) sets the rules, and the client establishes a connection with the server, then through port 21, if you want to transmit data, you have to go through port 20. The combination of port 20 and port 21 is the active mode of FTP.
  • Passive mode: Active mode has some security issues. If someone wants to attack your FTP service, they will directly block you at port 20. In order to avoid data being blocked when going out, passive mode appears. Passive mode changes the port 20 for data transmission to a range, such as 21100-21110 in the above text. The specific value is determined by the client (such as 21115). In this way, the outgoing data is not easily blocked, and security is greatly improved. Most FTP clients now use passive mode to connect to the server by default, that is, the port for data transmission is determined by the client.

-e means to append parameters

FTP_USER is the FTP login user name, setting example FTP_USER=zhaoolee

FTP_PASS is the ftp login password, setting example FTP_PASS=eelooahz

PASV_ADDRESS is the external network IP address, for example PASV_ADDRESS=104.243.20.148 (very important: you must bind the host's external IP address here, otherwise you will not be able to connect later. Zhaoolee spent a long time adjusting this...)

PASV_MIN_PORT is the minimum port number for the client to connect to the server, which is 21100 (the minimum port number for the server in passive mode)

PASV_MAX_PORT is the maximum port number for the client to connect to the server, which is 21110 (the maximum port number for the server in passive mode)

--name zhaoolee_vsftpd means the container name is zhaoolee_vsftpd (this name can be customized)

--restart=always means restart is possible

fauria/vsftpd represents the image name

Test with Alibaba Cloud

Open port 20, port 21, port range 21100-21110

Create a container

Connection test (FillZilla download link: https://filezilla-project.org/download.php?type=client)

Upload files via ftp

summary:

FTP is a commonly used service. Here we use vsftp's docker method to complete the construction, and it can be done with one line of command.
Docker image fauria/vsftpd Open source address: https://github.com/fauria/docker-vsftpd, you can find detailed operation documents

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • docker pure-ftp How to build an ftp server

<<:  Some slightly more complex usage example codes in mysql

>>:  How to change the database data storage directory in MySQL

Recommend

Docker core and specific use of installation

1. What is Docker? (1) Docker is an open source t...

How to optimize MySQL index function based on Explain keyword

EXPLAIN shows how MySQL uses indexes to process s...

MySQL Server IO 100% Analysis and Optimization Solution

Preface During the stress test, if the most direc...

How to use react-color to implement the front-end color picker

background We can use react-color to implement th...

JavaScript quickly implements calendar effects

This article example shares the specific code of ...

IE6/7 is going to be a mess: empty text node height issue

Preface: Use debugbar to view document code in iet...

Basic HTML directory problem (difference between relative path and absolute path)

Relative path - a directory path established based...

Sharing ideas on processing tens of millions of data in a single MySQL table

Table of contents Project Background Improvement ...

A brief analysis of the responsiveness principle and differences of Vue2.0/3.0

Preface Since vue3.0 was officially launched, man...

Setting up a proxy server using nginx

Nginx can use its reverse proxy function to imple...

Install Centos7 using Hyper-v virtual machine

Table of contents introduce Prepare Download syst...

How to upgrade https under Nginx

Purchase Certificate You can purchase it from Ali...