liveBook · Manning

Redis

As explained in Learn Docker in a Month of Lunches, Second Edition

Redis is an open-source in-memory data structure store that can function as a database, cache, and message broker.

Redis is an in-memory data structure store that can serve as a database, cache, or message broker. Here it provides asynchronous messaging: components publish messages to a queue instead of communicating directly, improving flexibility, performance, and scalability. section 21.0 section 21.1

A practical Redis messaging workflow uses separate containers for the queue, publisher, and subscriber:

  • Create a Docker network and start a Redis server listening on port 6379. section 21.1
  • Run the Redis CLI to publish the message "ping" repeatedly on the channel "channel21". section 21.1
  • Start an interactive subscriber and observe each published message arriving through the channel. section 21.1

Publish and subscribe with containers

Start Redis with the diamol/redis:2e image, publish "ping" 50 times at five-second intervals using the Redis CLI, and subscribe to channel21 in another container. The subscriber receives a copy of every published message. section 21.1

# create the network - on Linux containers:
docker network create ch21
# OR Windows Server containers:
docker network create -d nat ch21
# run the Redis server:
docker container run -d --name redis --network ch21 diamol/redis:2e
# check that the server is listening:
docker container logs redis --tail 1

Use the container commands to create the network, launch Redis, and verify from the logs that the server is listening. section 21.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates container setup, publishing, subscribing, and protocol rationale, but does not detail Redis database or cache operations.
Examples
Uses Docker containers, Redis CLI commands, channel21, and repeated ping messages to demonstrate publishing and subscription.
What you can do after
Operate/configure Redis in Docker, publish messages with the Redis CLI, and verify delivery through a subscriber.
How it connects
Connects Redis with message queues, asynchronous messaging, Docker, subscribers, publishers, and REST APIs.

Also explained in

Compare how 6 books explain Redis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.