I am getting this error while loading index.php file.

Warning: session_start(): Cannot find save handler 'redis' - session startup failed in /var/www/html/index.php on line 2

My index.php code looks like below:

$json['time ']= date(' Y-m-d H:i:s');
$json['ip ']=$_SERVER['REMOTE_ADDR'];
$json['count '] = $_SESSION['count'];
echo json_encode($json);


My dockerfile is like below:

FROM php:7.1-fpm-alpine

RUN apk update; \
    apk upgrade;

RUN apk add --update \
        autoconf \
        g++ \
        libtool \

RUN pecl install -o -f redis \
&&  rm -rf /tmp/pear \
&&  docker-php-ext-enable redis

# For easy navigating add oh my zsh and it's deps
RUN apk -q add curl \
    zsh \
    nano \
    git; \
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"; \
    sed -i s^ZSH_THEME=\"robbyrussell\"^ZSH_THEME=\"blinks\"^g ~/.zshrc;

# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"; \
    php composer-setup.php; \
    php -r "unlink('composer-setup.php');"; \
    echo 'alias composer="php /var/www/html/composer.phar" > ~/.zshrc';

My php.ini file is like below:

session.save_handler = redis
session.save_path = tcp://

Redis.conf file has a below entry:


My redis dockerfile is like below:

FROM redis:3.2-alpine

COPY conf/redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]


If I need to provide more details please let me know.

What could be the problem here?

  • How are you running these containers? Inter-container networking in Docker is rather tricky and not straight-forward. Can you access redis from your host machine? May 5 '18 at 17:03
  • 1
    Yes, however, I wanted to keep it that way. I have fixed my issue though, using a different version of phpredis. I will update this question with my answer soon. May 6 '18 at 14:55
  • Could you post an answer?
    – 030
    Dec 23 '19 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.