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:

  • Why the Linux total storage auto increase?
  • udp traffic with Iperf for haproxy
  • How to connect SSMS to Linux SqlServer in docker container?
  • Docker: creating multiple containers from only one image
  • set docker container env from daemon configuration file
  • How to export the data in docker container?
  •  $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?

  • push updates to gcloud containers/pods
  • How to define Kubernetes Job using a private docker registry?
  • Is it possible to access a hardware device with a docker image under Windows?
  • Cannot delete file from docker instance
  • Mac OS X Docker baseline aspnet error: libdl not found
  • Permission error when deploying Docker app from CI server to Heroku
  • 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.