【发布时间】:2021-04-12 15:11:16
【问题描述】:
我无法连接到 docker 容器 ftp 服务器。这是我的 docker 文件:
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
WORKDIR /app
COPY . ./
RUN dotnet publish MD.Ftp.Server -c Release -o out -r linux-x64
FROM mcr.microsoft.com/dotnet/runtime:5.0
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT ["dotnet", "MD.Ftp.Server.dll"]
EXPOSE 6001/tcp
为了运行 FTP 服务器,我通过以下方式创建 TcpListener:
tcpListener = new TcpListener(new IPEndPoint(IPAddress.Any, settings.Port));
当我从 IDE 本地运行它时,我可以使用 FileZilla 连接到它。当我在容器内运行它时 - 运气不好。我做错了什么?
FileZilla 日志:
Status: Disconnected from server
Status: Connecting to 127.0.0.1:6001...
Status: Connection established, waiting for welcome message...
Status: Plain FTP is insecure. Please switch to FTP over TLS.
Status: Logged in
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/"
Command: TYPE I
Response: 200 In IMAGE type
Command: PASV
Response: 227 Enter Passive Mode (172,17,0,2,234,142)
Command: LIST
Response: 150 File is Ok, about to open connection.
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
Status: Connecting to 127.0.0.1:6001...
Status: Connection established, waiting for welcome message...
Status: Plain FTP is insecure. Please switch to FTP over TLS.
Status: Logged in
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/"
Command: TYPE I
Response: 200 In IMAGE type
Command: PASV
Response: 227 Enter Passive Mode (172,17,0,2,234,143)
Command: LIST
Response: 150 File is Ok, about to open connection.
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
但是我在应用程序日志中看不到任何内容...不确定发生了什么
【问题讨论】:
标签: c# docker .net-core tcp tcplistener