Unable to list the external ftp directory listing using docker

I have docker environment running with docker for windows and want to connect and get the content from external ftp with passive mode. I am able to connect to the ftp but couldn’t able to get the directory listing. I am using Apache FTP Client with Java for this. I am getting connection refused post successful connect test using client when try to get the directory details.

Any help in this regards will be good help.

Where is that “external ftp”? Is it on your local machine(which is external to Docker Desktop) or on a remote server?

I assume Apache FTP Client is a dependency for your own Java implementation.
If so, did you check whether your implementation actualy works outside a container?
With passv mode ftp, it should not matter if your ftp client is containerized or not.

Side note: I can’t believe ftp still is a thing in 2022 :slight_smile:

FTP is in my local. It works fine if using same local ftp without docker. I have also used non-local ftp with docker and same also working but only having problem with local ftp. It seems there is issue with connecting to local ftp.

Are you trying to use “localhost:21” to access you local ftp? This will only work, if your container is started with --network=host. Otherwise localhost inside the container is local to the container, and not the localhost of your host itself.

With passv ftpd the server will tell the client on which ip:port it expects the next data connection. I assume this will be the next challenge you are going to stumle accross. Most ftpd servers allow to configure an ip to be used for passv mode and allow to set an ip-range for it. Once configured you can not use any other ip then the passv mode ip to access the ftpd.