How to do SFTP (SSH FTP) to a docker container running VSFTPD?


  • I have docker container running VSFTPD
  • While running docker image, I have ports mappings like below “-p 20:20/tcp -p 21:21/tcp -p 2222:22/tcp”

My requirement is do SFTP (SSH FTP and not FTPS using SSL) to get some files from the docker container.

I am able to normal FTP using anonymous . But facing issues with SFTP. Any inputs on how to go about this. Do I need to have SSHD running inside the container?


Ports 20 and 21 are used by active ftp, where port 21 is used to establish the control channel and Port 20 is used for data connection. The server activly connects the client to push the data, thus the client must be reachable from the internet, which will not work if the client is behind a NAT.

While passiv ftp is the common usage szenario, where a client still connects on port 21 (unless you change it) and the server tells the client ports to access for the data connections. You need to declare a passiv port range in the ftpd configuration and of course in the port mapping.

Which service ARE you running inside the container on port 22? Last time i checked there was no magic that made services reachable, just because I mapped a port outside the container.