Sign inSign up

imoize/redis

By imoize

•Updated over 2 years ago

Lightweight Redis Docker Image

Image
2

1.2K

imoize/redis repository overview

⁠Redis Docker Image

Custom image based on alpine with s6-overlay.

Github Build Status GitHub GitHub Package Repository Docker Pulls

⁠Supported Architectures

Multi-platform available trough docker manifest. More information is available from docker here⁠.

Simply pulling using latest tag should retrieve the correct image for your arch.

The architectures supported by this image:

ArchitectureAvailable
x86-64✅
arm64✅

⁠Usage

Here are some example to help you get started creating a container, easiest way to setup is using docker-compose or use docker cli.

  • docker-compose (recommended)
---
version: "3.9"
services:
  redis:
    image: imoize/redis:latest
    container_name: redis
    ports:
      - 6379:6379
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=Asia/Jakarta
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - /path/to/app/data:/config/redis
    restart: always
  • docker cli
docker run -d \
  --name=redis \
  -p 6379:6379
  -e PUID=1001 \
  -e PGID=1001 \
  -e TZ=Asia/Jakarta \
  -e ALLOW_EMPTY_PASSWORD=yes \
  -v /path/to/app/data:/config/redis \
  --restart always \
  imoize/redis:latest

⁠Available environment variables:

NameDescriptionDefault Value
PUIDUser UID
PGIDGroup GID
TZSpecify a timezone see this list⁠.UTC
S6_VERBOSITYControls the verbosity of s6-rc. See this.⁠1
ALLOW_EMPTY_PASSWORDAllow password-less accessno
REDIS_PASSWORDSetting the server password on first run.
EXTRA_FLAGSAdd extra command-line flags to redis-server startup.

NOTE: The at sign (@) is not supported for REDIS_PASSWORD

⁠Configuration

⁠Environment variables

When you start the redis image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. Please note that some variables are only considered when the container is started for the first time. If you want to add a new environment variable:

  • for docker-compose add the variable name and value:
redis:
    ...
    environment:
      - PUID=1001
      - ALLOW_EMPTY_PASSWORD=yes
    ...
  • for manual execution add a -e option with each variable and value:
  docker run -d \
  -e PUID=1001 \
  -e ALLOW_EMPTY_PASSWORD=yes \
  imoize/redis:latest
⁠EXTRA_FLAGS Usage

You can pass extra cmd via environment.

redis:
    ...
    environment:
      - PUID=1001
      - ALLOW_EMPTY_PASSWORD=yes
      - EXTRA_FLAGS="--maxmemory 128mb --maxmemory-policy allkeys-lru"
    ...
⁠Docker Secrets Support

You can append __FILE (double underscore) to REDIS_PASSWORD. It will be REDIS_PASSWORD__FILE.

services:
  redis:
      ...
      environment:
        - PUID=1001
        - ALLOW_EMPTY_PASSWORD=no
        - REDIS_PASSWORD__FILE="/run/secrets/redis_password"
      secrets:
        - redis_password

secrets:
  redis_password:
    external: true
      ...

⁠Volume

⁠Persisting your application

If you remove the container all your data will be lost, and the next time you run the image the data and config will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should map directory inside container in /config/redis path to host directory as data volumes. Application state will persist as long as directory on the host are not removed.

e.g: /path/to/app/data:/config/redis

redis:
    ...
    environment:
      - PUID=1001
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - /path/to/app/data:/config/redis
    ...

/config/redis folder contains redis relevant configuration files.

⁠User / Group Identifiers

For example: PUID=1001 and PGID=1001, to find yours user id and gid type id <your_username> in terminal.

  $ id your_username
    uid=1001(user) gid=1001(group) groups=1001(group)

⁠Tips / Info

  • Shell access whilst the container is running:
docker exec -it redis /bin/bash
  • To monitor the logs of the container in realtime:
docker logs -f redis
  • Container version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' redis
  • Image version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' imoize/redis:latest

⁠Upgrade this image

We recommend that you follow these steps to upgrade your container.

⁠Step 1: Get the updated image
docker pull imoize/redis:latest

or if you're using Docker Compose, update the value of the image property to imoize/redis:latest.

⁠Step 2: Stop currently running container

Stop the currently running container using this command.

docker stop redis

or using Docker Compose:

docker-compose stop redis
⁠Step 3: Remove currently running container

Remove the currently running container using this command.

docker rm -v redis

or using Docker Compose:

docker-compose rm -v redis
⁠Step 4: Run the new image

Re-create your container from the new image.

docker run --name redis imoize/redis:latest

or using Docker Compose:

docker-compose up -d redis
⁠Step 5: Remove the old dangling images

You can also remove the old dangling images.

docker image prune

⁠Contributing

We'd love for you to contribute to this container. You can submitting a pull request⁠ with your contribution.

⁠Issues

If you encountered a problem running this container, you can create an issue⁠.

Tag summary

Content type

Image

Digest

sha256:85a857328…

Size

12.2 MB

Last updated

over 2 years ago

docker pull imoize/redis