I run PHP-apache as a Docker container and I need to use Rsync inside of a PHP script - in exec() function.
I can't make it work with the 'default' Rsync - I mean, the one installed in the OS. I'm getting sh: 1: rsync: not found
. Same with pretty much any other command, except ssh
, ls
, id
- these work ok.
So I installed Rsync inside of the Docker PHP container, here's my Dockerfile:
FROM php:7.4-apache
LABEL maintainer="dev@chialab.io"
# Download script to install PHP extensions and dependencies
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync
RUN chmod go+x /usr/local/bin
RUN apt-get update
RUN apt-get -y install rsync
RUN DEBIAN_FRONTEND=noninteractive apt-get update -q \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y \
curl \
git \
zip unzip \
&& install-php-extensions \
mysqli \
pdo_mysql \
zip \
&& a2enmod rewrite
It builds fine, the PHP container runs ok, everything's good, BUT I still can't use Rsync in PHP's exec() function. Am I missing something?
Interesting enough, the container's rsync runs ok in terminal: $ docker exec php rsync ...
P.S. I'm still learning Docker, and I've been fighting with this nightmare for over a week now, and fixed a number of other issues along the way - and still no success. It took me a while before I fixed sh: 1: rsync: permission denied
with RUN chmod go+x /usr/local/bin
or made the rsync installed in container - it couldn't install at the beginning, but I fixed it by adding RUN apt-get update
right before the RUN apt-get -y install rsync
.