Skip to content

Add Redis Container

ucan-lab edited this page Jul 16, 2020 · 14 revisions

infrastructure/docker-compose.yml

volumes:
  redis-store:
services:
  redis:
    image: redis:6.0-alpine
    volumes:
      - redis-store:/data

infrastructure/docker/php/Dockerfile

ENV REDIS_HOST=redis
ENV CACHE_DRIVER=redis
ENV SESSION_DRIVER=redis
ENV QUEUE_DRIVER=redis

RUN git clone https://github.com/phpredis/phpredis.git /usr/src/php/ext/redis
RUN docker-php-ext-install redis

Redis for Laravel

$ make tinker
use Illuminate\Support\Facades\Redis;
Redis::set('name', 'hoge');
Redis::get('name');

Redis cli

$ docker-compose exec redis redis-cli

> flushall
OK

> set name "hoge"
OK
> get name
"hoge"
Clone this wiki locally