Knowledge
  • Read Me
  • Programming
    • ASP.NET
      • .NET Libraries
      • ASP.NET Core
        • Helper
          • Encryption
          • CSV Helper
          • String Helper
        • Logging
          • Simple Serilog
        • Middlewares
          • IP Restrictions
          • Request Throttling
          • Request Logging
        • Console
          • Command Line with arguments
        • JSON
      • ASP.NET Framework
      • Testing
        • Resources
        • xUnit.net
      • Naming Conventions
      • REST API Guidelines
    • Database
      • SQL Style Guide
      • MSSQL
        • Installation
          • Install MSSQL on MacOS M1 (ARM64)
        • Looping
        • Table Valued Functions
        • Session State
        • SQL Cheat Sheet
        • Export Pipe Delimited CSV With cmdshell
      • Redis
        • Redis Installation on Mac OS
        • Redis Installation on Docker
    • Java
      • AWS SDK - SSM
      • mTLS HTTP Connection
      • Read Resource Files
    • Javascript
      • Javascript Libraries
    • Python
    • OpenSSL
      • One Way SSL & Two Way SSL
      • Common OpenSSL Commands
      • Create Self-Signed Certificate
    • Misc
      • Git Commands
      • Windows Commands
      • PowerShell Commands
      • Vulnerabilities Dependency Check
      • Replace Filename Command
      • JSON Web Token (JWT)
      • Rabbit MQ Message-Broker
      • Pandoc Convert Document
  • DevOps
    • What is DevOps
    • CI & CD
    • Azure DevOps
  • Tools
    • Development Tools
Powered by GitBook
On this page
  • Prerequisites
  • Installation
  • Interact with Redis from your terminal
  • Reference

Was this helpful?

  1. Programming
  2. Database
  3. Redis

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:

docker pull redis

From the terminal, run:

docker run --name redis-container -p 6379:6379 -d redis:latest

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 as redis-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.

docker ps -a

Example

$ docker run --name redis-container -p 6379:6379 -d redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
33847f680f63: Pull complete
26a746039521: Pull complete
18d87da94363: Pull complete
5e118a708802: Pull complete
ecf0dbe7c357: Pull complete
46f280ba52da: Pull complete
Digest: sha256:cd0c68c5479f2db4b9e2c5fbfdb7a8acb77625322dd5b474578515422d3ddb59
Status: Downloaded newer image for redis:latest
eff7dedc53ec235068d543574111055a08d84b518f149ba6aac4adb6e63181d4

docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                       NAMES
eff7dedc53ec   redis     "docker-entrypoint.s…"   34 minutes ago   Up 28 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   redis-container

Interact with Redis from your terminal

Run redis-cli using this command:

docker exec -it redis-container redis-cli

Reference

PreviousRedis Installation on Mac OSNextJava

Last updated 2 years ago

Was this helpful?

Redis Command-line reference
Docker Command-line reference
Installing Redis Server Using Docker Container