fauria / docker-vsftpd

🐳 vsftpd Docker image based on Centos 7. Supports passive mode and virtual users.
https://hub.docker.com/r/fauria/vsftpd/
Apache License 2.0
414 stars 341 forks source link

How to configure PASV mode inside docker-compose file #21

Closed VEINHORN closed 2 years ago

VEINHORN commented 5 years ago

Hi @fauria!

When I use docker-vsftpd alogside docker-compose.yml I cannot properly use ftp ls command cause I get such error:

ftp> ls 500 Illegal PORT command. 425 Use PORT or PASV first.

Part of docker-compose.yml file:

ftp-server:
    image: fauria/vsftpd
    deploy:
      replicas: 1
    ports:
      - "20:20"
      - "21:21"
      - "21100-21110:21100-21110"
    environment:
      - FTP_USER=bob
      - FTP_PASS=12345
      - PASV_ADDRESS=my-host
      - PASV_ADDRESS_RESOLVE=YES
      - PASV_ADDR_RESOLVE=YES
      - PASV_MIN_PORT=21100
      - PASV_MAX_PORT=21110
      - PASV_ADDRESS_ENABLE=YES
      - PASV_ENABLE=YES
    networks:
      - webnet
    volumes:
      - "/opt/dockerstorage/volumes/ftpvolume/_data:/home/vsftpd"

But when I start ftp server with below command it works fine:

docker run -d -v /opt/dockerstorage/volumes/ftpvolume/_data:/home/vsftpd -p 20:20 -p 21:21 -p 21100-21110:21100-21110 -e FTP_USER=bob -e FTP_PASS=12345 -e PASV_ADDRESS=my-host -e PASV_MIN_PORT=21100 -e PASV_MAX_PORT=21110 -e PASV_ADDRESS_ENABLE=YES -e PASV_ENABLE=YES --name vsftpd --restart=always fauria/vsftpd

I think there are some troubles with address lookup but I couldn't find how to solve it.

Update: For now I need to use host network.

joekinley commented 5 years ago

This unfortunately has nothing to do with PASV mode as it also happens for me with the following entry in docker-compose

ftp:
    image: fauria/vsftpd
    environment:
      - FTP_USER=foo
      - FTP_PASS=bar
      - PASV_ENABLE=NO
      - PASV_ADDRESS_RESOLVE=NO
      - PASV_ADDR_RESOLVE=NO
      - PASV_ADDRESS_ENABLE=NO
    ports:
      - "8020:20"
      - "8021:21"

Result:

ftp> ls
500 Illegal PORT command.
joekinley commented 5 years ago

Okay after some deeper research I figured that the linux ftp CLI does apparently not automatically switch to passive mode by somehow communicating with the server. You rather have to explicitly tell it to use passive mode. So if you go ftp -p hostname port, then it seemed to work in my configuration with the following docker-compose entry:

ftp:
    image: fauria/vsftpd
    environment:
      - FTP_USER=foo
      - FTP_PASS=bar
      - PASV_ADDRESS_RESOLVE=YES
      - PASV_ADDR_RESOLVE=YES
      - PASV_MIN_PORT=21100
      - PASV_MAX_PORT=21110
      - PASV_ADDRESS_ENABLE=YES
      - PASV_ENABLE=YES
      - LOG_STDOUT=1
    volumes:
      - ./support/vsftpd:/home/vsftpd
    ports:
      - "8020:20"
      - "8021:21"
      - "21100:21100"
      - "21101:21101"
      - "21102:21102"
      - "21103:21103"
      - "21104:21104"
      - "21105:21105"
      - "21106:21106"
      - "21107:21107"
      - "21108:21108"
      - "21109:21109"
      - "21110:21110"
Slach commented 2 years ago

my worked solution

version: "3.3"
services:
  ftp:
    image: docker.io/fauria/vsftpd:latest
    container_name: ftp
    environment:
      FTP_USER: user
      FTP_PASS: password
      PASV_ENABLE: "YES"
      PASV_ADDRESS: "ftp"
      PASV_ADDR_RESOLVE: "YES"

@fauria let's close the issue