docker-compose.yaml

version: "3.9"
services:
  vsftp:
    image: fauria/vsftpd
    restart: always
    container_name: vsftp
    volumes:
      - './logs:/var/log/vsftpd:rw'
      - '/dataB/www/:/home/vsftpd'
    ports:
      - "21:21"      
      - "2001-2020:2001-2020"
    privileged: true 
    environment:
      - TZ=Asia/Shanghai
      - FTP_USER=user
      - FTP_PASS=password
      - PASV_MIN_PORT=2001
      - PASV_MAX_PORT=2020
      - PASV_ADDRESS=172.16.1.130 #本机ip
      - LOG_STDOUT=1

说明:

https://www.it610.com/article/1277825965245874176.htm
https://blog.csdn.net/weixin_41753664/article/details/123374929

https://hub.docker.com/r/fauria/vsftpd

fauria/vsftpd
PASV_ADDRESS这个环境变量必须配置(如果你不需要被动模式可以无视)

添加新用户 设置目录

docker exec -it vsftpd bash
mkdir /home/vsftpd/zhang
chown -R ftp:ftp /home/vsftpd/zhang #设置权限

vi /etc/vsftpd/virtual_users.txt #奇数行用户名 偶数行密码
/usr/bin/db_load -T -t hash -f /etc/vsftpd/virtual_users.txt /etc/vsftpd/virtual_users.db
exit
docker restart vsftpd