I'm trying to connect to an FTP server programmatically. The language of my choice is Python, which is simple enough:
from ftplib import FTP
ftp = FTP(host=FTP_HOST, user=FTP_USERNAME, passwd=FTP_PASSWORD)
ftp.dir()
If I run these three lines on my local machine, it returns a filelist (nlst works as well, as a sidenote). If I now run my Docker container, enter it (docker exec), and go to python, and try to run the same three commands there, it produces a timeout.
I originally suspected it has something to do with the ports, so I exposed port 21, and instructed ftplib to operate over the exposed port, but this gave the same behaviour.
Does anyone have an idea on how to figure out why it works fine locally, but refuses in a container?
EDIT: I'm using passive FTP, and the server is not running on my local machine.