title: Redis is not saving PHP Session in Docker Container
body: <p>I have been trying to achieve session handler between PHP and Redis. I have configured everything (as per my knowledge and understanding) and there is no error as such. But still, I am not able to see any sessions are getting generated in Redis for PHP code.</p>
  
  <p>my PHP Code:</p>
  
  <pre><code>&lt;?php 
  session_start(); 
  $_SESSION['count']=(isset($_SESSION['count']))?$_SESSION['count']+1:1; 
  $json['time ']= date(' Y-m-d H:i:s'); 
  $json['ip ']=$_SERVER['REMOTE_ADDR']; 
  $json['count '] = $_SESSION['count']; 
  echo json_encode($json);
  
  ?&gt;
  </code></pre>
  
  <p>Php and Redis docker-compose.yml entries are below:</p>
  
  <pre><code>php:
      image: php:7.1-fpm-alpine
      build: './.setup/php/'
      volumes:
        - ./public_html/:/var/www/html/
        - ./.setup/php/php.ini:/usr/local/etc/php/php.ini
        - ./.setup/php/docker-php-ext-redis.ini:/usr/local/etc/php/conf.d/docker-php-ext-redis.ini
      links:
        - redis:cacheserver
      networks:
        public_net:
          ipv4_address: ${PHP_IP}
  
  redis:
      build: ./.setup/cache
      networks:
        public_net:
          ipv4_address: ${REDIS_IP}
      container_name: cacheserver
  </code></pre>
  
  <p>Dockerfile for PHP:</p>
  
  <pre><code>FROM php:7.1-fpm-alpine
  
  RUN echo http://uk.alpinelinux.org/alpine/latest-stable/community/  &gt;&gt; /etc/apk/repositories \
      &amp;&amp; apk add --no-cache shadow curl vim zlib-dev autoconf g++ make re2c \
      &amp;&amp; pecl install -o -f redis \
      &amp;&amp; docker-php-ext-enable redis.so \
      &amp;&amp; pecl clear-cache
  </code></pre>
  
  <p>Dockerfile for Redis:</p>
  
  <pre><code>FROM redis:3.2-alpine
  
  COPY conf/redis.conf /usr/local/etc/redis/redis.conf
  CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
  
  EXPOSE 6379
  </code></pre>
  
  <p>Content of php.ini and docker-php-ext-redis.ini:</p>
  
  <pre><code>extension=redis.so
  </code></pre>
  
  <p>I tried to put below entries into php.ini, however, it is throwing an error, as of now I commented them:</p>
  
  <pre><code>#session.save_handler = redis
  #session.save_path = tcp://192.168.0.24:6379
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Warning: session_start(): Cannot find save handler 'redis' - session
    startup failed in /var/www/html/index.php on line 2</p>
  </blockquote>
  
  <p>Redis.conf file only has below entry to receive a request from anywhere:</p>
  
  <blockquote>
    <p>bind 0.0.0.0</p>
  </blockquote>
  
  <p>Now I dont know, what is the problem, most importantly, I am not getting how will they both communicate. In my docker-compose.yml file, I have configured a fixed network and configured a static IP for both.</p>
  
  <p>Any suggestion please.</p>