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:

  • Private Network broken in Vagrant with Docker
  • Using ENTRYPOINT in a Dockerfile makes the base image's CMD be ignored
  • Connection refused while connecting to a docker image deployed on Elastic Beanstalk
  • Dockercloud service stops immediately after start
  • How can I expose more than 1 port with Docker?
  • Docker, php and python
  •  $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?

  • (psycopg2.OperationalError) could not connect to server: Connection refused Is the server
  • How deploy spring cloud data flow on docker
  • Increasing the AWS ECS Task Definition reserved ports limit
  • How to downloaded from remote location and execute script on container start Docker?
  • docker-compose - how to escape environment variables
  • NodeJs development offline in docker
  • 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.