php ftp_get() not working in Docker container

I am trying to retrieve a file from an ftp in a Docker container using php. The script I have works locally, but the file is not being retrieved from Docker. Here is my Dockerfile

FROM debian:jessie
RUN apt-get update && apt-get install -y php5-cli php5-curl git cron ca-certificates
CMD ["/"] just downloads the actual script to run from source control, and sets up a cron job. The call to the ftp is this:

  • Docker container sending empty responses
  • Can't start application within docker using linked mysql database
  • Can't run tomcat in docker, how can I run the container by it's id?
  • Fail to expose my pod to the internet
  • How to compile apache2 own module in dockerfile?
  • How to SSH into Docker?
  •  $connection = ftp_connect('');
     $login = ftp_login($connection, 'myusername', 'mypassword');
     ftp_get($connection, 'localfile.xml', 'remotefile.xml', FTP_BINARY);

    The erros we receive are

    ftp_fget(): Switching to Binary mode.

    followed by

    FTP Pull failed

    Is there anything else I need to install in my container to get this to work?

  • why docker not executing init as lxc
  • Node size on GKE kubernetes
  • GitLab Ci with docker runner - Multiple Stages
  • How to get docker images from privacy AWS ECR repository in Vagrant
  • Iptables to forward remote port to local port for local access
  • Odd behaviour of dnsmasq across docker containers
  • One Solution collect form web for “php ftp_get() not working in Docker container”

    We needed to add

    ftp_pasv($connection, TRUE); 

    before the ftp_get(). This is the working solution:

    $connection = ftp_connect('');
    $login = ftp_login($connection, 'myusername', 'mypassword');
    ftp_pasv($connection, TRUE); 
    ftp_get($connection, 'localfile.xml', 'remotefile.xml', FTP_BINARY);
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.