Start redis docker container on RHEL7

This article will show you how to run a redis container with docker image on RHEL7.

Get a copy of redis official conf file

Get a official copy of redis configuration file, which can be customized by needs, example file can be found here

Create scripts to run redis docker container

# Example of scripts to run redis docker container with conf file.
# The example use default port(6379) with let's encrypt support (once you have your domain name configured,
# redis server can be accessed over https.
# The redis docker image version is 7.0.5

docker run -d \
  -p 6379:6379 \
  --name redis \
  -e LETSENCRYPT_HOST=your.redis.host.url \
  -e LETSENCRYPT_EMAIL=yourname@email.com \
  -v "$(pwd)"/conf:/usr/local/etc/redis \
  redis:7.0.5 \
  /usr/local/etc/redis/redis.conf

Verify your redis container

# Run docker command to check redis server status

[myname@host]$ docker ps -a
# Output:
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
5f0a8d455eb4   redis:7.0.5               "docker-entrypoint.s…"   11 minutes ago   Up 11 minutes             0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   redis

# run redis cli inside container
[myname@host]$ docker exec -it redis bash
# You'll see below path, then type redis-cli
root@b1f766796a42:/data# redis-cli

# Now you connected to redis container
127.0.0.1:6379> ping
PONG
# Above message indicates your redis server is running correctly.

Reference:

Scroll to Top