Redis Installation on Docker
Prerequisites
To use Docker on your laptop, you need to install Docker Desktop. There is a version for Mac, Windows, and Linux.
Installation
From the terminal, run:
From the terminal, run:
This will create a container with default redis port 6379, you translate the command as:
docker run
- Run a command in a new container--name <your-container-name>
- Assign a name to the container to be created, in this example, it will be named asredis-container
-p 6379:6379
- Publish or expose port (-p, --expose). In this example, this binds port 6379 of the container to TCP port 6379 on 127.0.0.1 (localhost) of the host machine (local machine). You can also specify udp and sctp ports.-d redis:latest
- Run redis container in background and print container ID
Next, run the command below to show all containers, to verify if the container created is running.
Example
Interact with Redis from your terminal
Run redis-cli using this command:
Reference
Last updated