Setup Redis Docker Container to Use with Laravel App

Ibrar Hussain
1 min readJan 12, 2024

If you are working on Laravel project optimization, you might have considered using cache, with Redis being a popular choice. Laravel provides support for multiple cache drivers, including Redis.

To start using Redis, you’ll first need to install the phpredis package. You can do this by running the following command:

composer require predis/predis

Next, update your .env file and change the CACHE_DRIVER value to redis:

CACHE_DRIVER=redis

Now, let’s set up Redis using a Docker container. If you don’t have Docker Desktop installed, follow these steps:

Install Docker Desktop

  1. Download Docker Desktop:
    Visit the Docker Desktop website and download the appropriate version for your operating system.
  2. Install Docker Desktop:
    Follow the installation instructions for your operating system.

Set Up Redis with Docker

  • Create a Folder:
mkdir docker-workspace
  • Navigate to the Folder:
cd docker-workspace
  • Create a Docker Compose File:
touch docker-compose.yml
  • Open docker-compose.yml and Add the Following Content:
version: "3.7"
services:
# Redis Server for Cache
redis-cache:
image: redis:latest…

--

--

Ibrar Hussain

I am a full stack web developer with experience working on Laravel and Vue. I am passionate about exploring and learning new technologies in the field.