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

How to configure eureka in docker

eureka: 1. Build a JDK image Start the eureka con...

Examples of using provide and inject in Vue2.0/3.0

Table of contents 1. What is the use of provide/i...

Use Vue3 for data binding and display list data

Table of contents 1. Comparison with Vue2 1. New ...

MySQL 8.0.12 installation steps and basic usage tutorial under Windows

This article shares the installation steps and us...

Detailed analysis of Vue child components and parent components

Table of contents 1. Parent components and child ...

Tomcat configuration and how to start it in Eclipse

Table of contents How to install and configure To...

How to reference jQuery in a web page

It can be referenced through CDN (Content Delivery...

How to quickly install Nginx in Linux

Table of contents What is nginx 1. Download the r...

SQL implementation of LeetCode (197. Rising temperature)

[LeetCode] 197.Rising Temperature Given a Weather...

XHTML three document type declarations

XHTML defines three document type declarations. T...

Two ways to install the Linux subsystem in Windows 10 (with pictures and text)

Windows 10 now supports Linux subsystem, saying g...