连接到在docker中运行的ftp服务器

时间:2019-02-14 02:46:57

标签: docker vsftpd

我在Windows主机上的Docker容器中运行ftp服务器。我已经将(-p)端口22和21映射为SSH和FTP。我无法从主机成功建立与FTP服务器的FTP连接。看起来ftp客户端(可爱的FTP)使用随机端口列出目录和文件,而这正是连接断开的地方。使用凭据查看日志连接会成功,但是稍后在列出目录时失败并断开连接。我试图弄清楚如何在Docker容器中设置ftps服务器,而ftp客户端使用随机端口进行成功连接。仅供参考,我尝试了PORT和PASIVE连接类型,但都没有用。这是我的cuteftp连接日志:

*** 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.

我运行了以下命令来启动ubuntu容器

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

使用所需的更改对vsftpd.conf进行了编辑。基于cuteftp日志,我获得了完全连接,但目录和文件未列出,因为cuteftp使用随机端口进行会话以显示文件和目录。我只有端口80、22和21映射到了容器。

没有用例。我是docker的新手,可以玩耍和学习。我想运行ubuntu容器,然后在其上安装LAMP。我对LAMP的安装非常满意,但随后需要FTP服务器将文件上传到html文件夹以测试站点。这只是学习。我知道我可以找到已经安装了LAMP的docker映像,但这不是学习的方法。我确实对运行ubuntu容器有疑问,我相信我已经分别询问了它(单独的问题),并等待有人对此进行答复。

根据您的建议,我尝试过

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

,这不起作用。我什至无法对容器执行SSH,所以--network host不会将所有端口都传递给容器。

0 个答案:

没有答案
相关问题