2

i have ftp server running in Docker container on windows host. i have mapped (-p) port 22 and 21 for SSH and FTP. i can't make successful FTP connection to ftp server from host. looks like ftp client (cute FTP) uses random ports to list directories and files and this is where connection dropped. looking at the log connection using credentials goes successful but later when time comes to list directories it failed and disconnects. I’m trying to figure out how to setup ftps server in Docker container where ftp client uses random ports to make successful connection. FYI, i have tried both PORT and PASIVE connection types and both didn't work. Here is my cuteftp connection log:

*** CuteFTP 8.0 - build Aug 22 2006 ***

STATUS:>    [2/13/2019 11:22:56 AM] Getting listing ""...
STATUS:>    [2/13/2019 11:22:56 AM] Resolving host name localhost...
STATUS:>    [2/13/2019 11:22:56 AM] Host name localhost resolved: ip = 127.0.0.1.
STATUS:>    [2/13/2019 11:22:56 AM] Connecting to FTP server... localhost:2121 (ip = 127.0.0.1)...
STATUS:>    [2/13/2019 11:22:56 AM] Socket connected. Waiting for welcome message...
        [2/13/2019 11:22:56 AM] 220 (vsFTPd 3.0.3)
STATUS:>    [2/13/2019 11:22:56 AM] Connected. Authenticating...
COMMAND:>   [2/13/2019 11:22:56 AM] USER ftpuser
        [2/13/2019 11:22:56 AM] 331 Please specify the password.
COMMAND:>   [2/13/2019 11:22:56 AM] PASS *****
        [2/13/2019 11:22:56 AM] 230 Login successful.
STATUS:>    [2/13/2019 11:22:56 AM] Login successful.
COMMAND:>   [2/13/2019 11:22:56 AM] PWD
        [2/13/2019 11:22:56 AM] 257 "/" is the current directory
STATUS:>    [2/13/2019 11:22:56 AM] Home directory: /
COMMAND:>   [2/13/2019 11:22:56 AM] FEAT
        [2/13/2019 11:22:56 AM] Informational Message Only:
        211-Features:
         EPRT
         EPSV
         MDTM
         PASV
         REST STREAM
         SIZE
         TVFS
        211 End
STATUS:>    [2/13/2019 11:22:56 AM] This site supports features.
STATUS:>    [2/13/2019 11:22:56 AM] This site supports SIZE.
STATUS:>    [2/13/2019 11:22:56 AM] This site can resume broken downloads.
COMMAND:>   [2/13/2019 11:22:56 AM] REST 0
        [2/13/2019 11:22:56 AM] 350 Restart position accepted (0).
COMMAND:>   [2/13/2019 11:22:56 AM] PASV
        [2/13/2019 11:22:56 AM] 227 Entering Passive Mode (172,17,0,2,202,168).
STATUS:>    [2/13/2019 11:22:56 AM] Substituting received PASV address 172.17.0.2 to server address 127.0.0.1.
COMMAND:>   [2/13/2019 11:22:56 AM] LIST
STATUS:>    [2/13/2019 11:22:56 AM] Connecting FTP data socket... 127.0.0.1:51880...
ERROR:>     [2/13/2019 11:22:57 AM] The remote host actively refused the attempt to connect to it.
        1) Verify that the destination server name or IP address is correct
        2) Verify that the connection port number is correct (under Site Settings | Type tab).
        3) The remote server may be temporarily or permanently inaccessible (try again later).
        4) Verify that you have chosen the right protocol (SSH2, SSL, FTP, etc.) and have setup all required options for that protocol.
        5) Verify that the destination IP address and port numbers are correct.
        6) The remote server may be refusing multiple connections from the same client. Try using only one connection thread when connecting to this particular server (Site Settings | Options).
        7) Try pinging the address.
        8) If you are using a router, verify the router is up and running (check by pinging it and then ping an address outside of the router).
        9) Do a traceroute to the destination to verify all routers along the connection path are operational.
        10) Verify that your subnet mask is setup properly.
        11) Verify that your local software or hardware firewall is not blocking outbound connections originating from CuteFTP.
        12) Verify that your anti-virus software is not at fault (try disabling it).
ERROR:>     [2/13/2019 11:22:57 AM] PASV failed, trying PORT.
STATUS:>    [2/13/2019 11:22:57 AM] Waiting 0 seconds...
STATUS:>    [2/13/2019 11:22:57 AM] Getting listing "/"...
STATUS:>    [2/13/2019 11:22:57 AM] Resolving host name localhost...
STATUS:>    [2/13/2019 11:22:57 AM] Host name localhost resolved: ip = 127.0.0.1.
STATUS:>    [2/13/2019 11:22:57 AM] Connecting to FTP server... localhost:2121 (ip = 127.0.0.1)...
STATUS:>    [2/13/2019 11:22:57 AM] Socket connected. Waiting for welcome message...
        [2/13/2019 11:22:57 AM] 220 (vsFTPd 3.0.3)
STATUS:>    [2/13/2019 11:22:57 AM] Connected. Authenticating...
COMMAND:>   [2/13/2019 11:22:57 AM] USER ftpuser
        [2/13/2019 11:22:57 AM] 331 Please specify the password.
COMMAND:>   [2/13/2019 11:22:57 AM] PASS *****
        [2/13/2019 11:22:57 AM] 230 Login successful.
STATUS:>    [2/13/2019 11:22:57 AM] Login successful.
COMMAND:>   [2/13/2019 11:22:57 AM] PWD
        [2/13/2019 11:22:57 AM] 257 "/" is the current directory
STATUS:>    [2/13/2019 11:22:57 AM] Home directory: /
STATUS:>    [2/13/2019 11:22:57 AM] This site supports features.
STATUS:>    [2/13/2019 11:22:57 AM] This site supports SIZE.
STATUS:>    [2/13/2019 11:22:57 AM] This site can resume broken downloads.
COMMAND:>   [2/13/2019 11:22:57 AM] REST 0
        [2/13/2019 11:22:57 AM] 350 Restart position accepted (0).
COMMAND:>   [2/13/2019 11:22:57 AM] PORT 127,0,0,1,205,112
        [2/13/2019 11:22:57 AM] 500 Illegal PORT command.
ERROR:>     [2/13/2019 11:22:57 AM] Syntax error: command unrecognized.
ERROR:>     [2/13/2019 11:22:57 AM] Failed to establish data socket.

i ran the following command to start ubuntu container

docker -dit --name ubuntu -p 80:80 -p 22:22 -p 21:21 ubuntu
docker exec -it ubuntu bash
apt update
apt install vfstpd

edited the vsftpd.conf with required changes. Based on the cuteftp log i'm getting sucefull connection but directories and files are not listing because cuteftp is using random ports for session to display files and directories. i have only ports 80, 22 and 21 mapped to container.

There is no use case. i'm new to docker and playing around and learning. i wanted to run ubuntu container and then install LAMP on it. i was sucessfull with LAMP installation but then needed FTP server to upload files to html folder to test site. this is just learning. i know i can find docker images with LAMP already installed but that is not learning. i do have questions on running ubuntu container and i believe i have asked it separately (separate question) and waiting somebody to reply on it.

as per your suggestion i have tried

 docker run -dit --name ubuntu --network host ubuntu

and this didn't work. i couldn't even able to do SSH to container so looks like --network host wouldn't pass all ports to container.

smaqsood
  • 1,559
  • 3
  • 11
  • 12
  • Please provide the ```Dockerfile``` and/or ```docker-compose.yml``` file and command line(s) you are using to start the FTP container. – Steve Boyd Feb 14 '19 at 03:30
  • There is no FTP container. i'm running ubuntu container and then running docker exec -it ubuntu bash to get inside the container and then setting up vsftpd server. – smaqsood Feb 14 '19 at 22:26
  • Could you please add any ```Dockerfile``` and/or ```docker-compose.yml``` file and command lines used to start your container(s) to your question. – Steve Boyd Feb 14 '19 at 23:19
  • added the command as requested. – smaqsood Feb 14 '19 at 23:25
  • Starting a full Ubuntu containerized distrb just to install and run an FTP server is really counter to the concept of containerization. Before we go any further with this, could you check out the https://hub.docker.com/r/stilliard/pure-ftpd container and see if it fits your FTP needs. If it doesn't could you add your actual use case to the question description. – Steve Boyd Feb 14 '19 at 23:56
  • added to question... – smaqsood Feb 16 '19 at 00:18
  • If you want to transfer files to your LAMP container I would simplify things by either mapping a volume to the host file system or using ```docker cp``` to copy your files from the host to the container. – Steve Boyd Feb 16 '19 at 05:06
  • mapping is on and off for me. On WP container mapping (volume) worked but on ubuntu container it never worked for me. i don't know why. I did -v ./html:/var/www/html – smaqsood Feb 16 '19 at 07:08

0 Answers0