I am experiencing an issue with FTP access from the host machine to a Docker container. FTP access works when I try directly from within the container. I am unsure where the problem lies.
Context:
I am using Apache NiFi 2.0-M2 deployed in a Docker container. I have configured a ListenFTP processor in NiFi to receive files via FTP on port 2221 and make them accessible from the host machine.
docker-compose.yml
Here is my docker-compose.yml configuration:
services:
nifi:
container_name: nifi
image: apache/nifi:2.0.0-M2
ports:
"8443:8443"
"2221:2221" # ftp
environment:
NIFI_WEB_HTTPS_PORT=8443
The port 2221 seems to be correctly mapped from the container to the host machine.
Connection Tests from the Host Machine:
Telnet:
telnet localhost 2221
Trying ::1... Connected to localhost. Escape character is '^]'. Connection closed by foreign host.
Netcat:
nc -zv localhost 2221
Connection to localhost port 2221 [tcp/rockwell-csp1] succeeded!
Curl:
curl -4 -v -u nbo:******* -T test2.txt ``ftp://localhost:2221
* Host localhost:2221 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\* Trying 127.0.0.1:2221...
* Connected to localhost (127.0.0.1) port 2221
* response reading failed (errno: 36)
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Closing connection
curl: (56) response reading failed (errno: 36)
FTP:
ftp localhost 2221
Connected to localhost. 421 Service not available, remote server has closed connection
Summary:
Despite the configurations and resolution attempts mentioned above, the FTP connection consistently fails from the host machine with errors indicating that the server closes the connection immediately. The tests show that the port is accessible, but the NiFi ListenFTP server does not seem to accept or properly handle FTP connections from outside the container.
Many thanks in advance for your help.
Nicolas