Docker Compose Redis configuration¶
The configuration for running a [[Redis]] server within Docker Compose primarily involves defining the service image and exposing the necessary network ports.
Configuration¶
The standard docker-compose.yml configuration uses the official redis image.^[600-developer-docker-docker-compose-docker-redis.md, 600-developer__docker__docker-compose__docker-redis.md]
To access the Redis service from the host machine, port mapping must be configured. This forwards the container's Redis port (6379) to the corresponding port on the host^[600-developer-docker-docker-compose-docker-redis.md, 600-developer__docker__docker-compose__docker-redis.md].
redis:
image: redis
ports:
- "6379:6379"
Accessing the CLI¶
To interact with the running Redis instance, the Redis command-line interface (redis-cli) can be executed directly inside the container^[600-developer-docker-docker-compose-docker-redis.md, 600-developer__docker__docker-compose__docker-redis.md].
docker exec -it <container_id> redis-cli
Sources¶
600-developer-docker-docker-compose-docker-redis.md600-developer__docker__docker-compose__docker-redis.md