Setup Redis Docker Container to Use with Laravel App
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
- Download Docker Desktop:
Visit the Docker Desktop website and download the appropriate version for your operating system. - 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…