GithubHelp home page GithubHelp logo

sameersbn / docker-redis Goto Github PK

View Code? Open in Web Editor NEW
155.0 8.0 138.0 72 KB

Dockerfile to create a Docker container image for Redis.

License: MIT License

Makefile 2.41% Shell 61.46% Dockerfile 36.12%

docker-redis's Introduction

Circle CI Docker Repository on Quay.io

sameersbn/redis

Introduction

Dockerfile to create a Docker container image for Redis.

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.

Contributing

If you find this image useful here's how you can help:

  • Send a pull request with your awesome features and bug fixes
  • Help users resolve their issues.
  • Support the development of this image with a donation

Issues

Before reporting your issue please try updating Docker to the latest version and check if it resolves the issue. Refer to the Docker installation guide for instructions.

SELinux users should try disabling SELinux using the command setenforce 0 to see if it resolves the issue.

If the above recommendations do not help then report your issue along with the following information:

  • Output of the docker version and docker info commands
  • The docker run command or docker-compose.yml used to start the image. Mask out the sensitive bits.
  • Please state if you are using Boot2Docker, VirtualBox, etc.

Getting started

Installation

Automated builds of the image are available on Dockerhub and is the recommended method of installation.

Note: Builds are also available on Quay.io

docker pull sameersbn/redis:4.0.9-2

Alternatively you can build the image yourself.

docker build -t sameersbn/redis github.com/sameersbn/docker-redis

Quickstart

Start Redis using:

docker run --name redis -d --restart=always \
  --publish 6379:6379 \
  --volume /srv/docker/redis:/var/lib/redis \
  sameersbn/redis:4.0.9-2

Alternatively, you can use the sample docker-compose.yml file to start the container using Docker Compose

Command-line arguments

You can customize the launch command of Redis server by specifying arguments to redis-server on the docker run command. For example the following command will enable the Append Only File persistence mode:

docker run --name redis -d --restart=always \
  --publish 6379:6379 \
  --volume /srv/docker/redis:/var/lib/redis \
  sameersbn/redis:4.0.9-2 --appendonly yes

Please refer to http://redis.io/topics/config for further details.

Persistence

For Redis to preserve its state across container shutdown and startup you should mount a volume at /var/lib/redis.

The Quickstart command already mounts a volume for persistence.

SELinux users should update the security context of the host mountpoint so that it plays nicely with Docker:

mkdir -p /srv/docker/redis
chcon -Rt svirt_sandbox_file_t /srv/docker/redis

Authentication

To secure your Redis server with a password, specify the password in the REDIS_PASSWORD variable while starting the container.

docker run --name redis -d --restart=always \
  --publish 6379:6379 \
  --env 'REDIS_PASSWORD=redispassword' \
  --volume /srv/docker/redis:/var/lib/redis \
  sameersbn/redis:4.0.9-2

Clients connecting to the Redis server will now have to authenticate themselves with the password redispassword.

Alternatively, the same can also be achieved using the Command-line arguments feature to specify the --requirepass argument.

Logs

By default the Redis server logs are sent to the standard output. Using the Command-line arguments feature you can configure the Redis server to send the log output to a file using the --logfile argument:

docker run --name redis -d --restart=always \
  --publish 6379:6379 \
  --volume /srv/docker/redis:/var/lib/redis \
  sameersbn/redis:4.0.9-2 --logfile /var/log/redis/redis-server.log

To access the Redis logs you can use docker exec. For example:

docker exec -it redis tail -f /var/log/redis/redis-server.log

Maintenance

Upgrading

To upgrade to newer releases:

  1. Download the updated Docker image:
docker pull sameersbn/redis:4.0.9-2
  1. Stop the currently running image:
docker stop redis
  1. Remove the stopped container
docker rm -v redis
  1. Start the updated image
docker run --name redis -d \
  [OPTIONS] \
  sameersbn/redis:4.0.9-2

Shell Access

For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version 1.3.0 or higher you can access a running containers shell by starting bash using docker exec:

docker exec -it redis bash

docker-redis's People

Contributors

dstengele avatar elouizbadr avatar shcarrico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-redis's Issues

Cannot change port using docker compose

Hi,

I have tried to change the port using the provided docker-compose.yml file, but this does not work.

This is the changed docker-compose.yml file:

version: '3.7'
services:
  redis:
    container_name: redis-basic
    hostname: redis
    image: sameersbn/redis:4.0.9-2
    ports:
      - "6380:6380"
    volumes:
      - type: volume
        source: redis-data
        target: /data
    restart: always
volumes:
  redis-data: {}

This is the node code I'm using to test it:

import redis from 'redis'

const config = {
  host: '127.0.0.1',
  port: 6380,
  no_ready_check: true
}

const client = redis.createClient(config.port, config.host)

client.set('expireName', 'nidkil', (err, reply) => {
  if (err) {
    console.error('Error occurred:', err)
  } else {
    console.log('Response:', reply)
  }
})

If I change the port back to 6379 in the docker-compose.yml file and the code then it works.

Any ideas how to change the port?

[IMPROVEMENT] Customize loglevel via environment variable

I'd like to modify the log level of redis.config. The logs of my docker-compose environment is flooded by plenty occurrences of the background saving:

redis_1      | [1] 06 Sep 13:37:30.029 * 10 changes in 300 seconds. Saving...
redis_1      | [1] 06 Sep 13:37:30.029 * Background saving started by pid 449
redis_1      | [449] 06 Sep 13:37:30.047 * DB saved on disk
redis_1      | [449] 06 Sep 13:37:30.048 * RDB: 0 MB of memory used by copy-on-write
redis_1      | [1] 06 Sep 13:37:30.129 * Background saving terminated with success

Using loglevel warning instead of loglevel notice would reduce the logs to "only very important / critical messages are logged" (as stated in redis.config).

Not compatible anymore with sameersbn/gitlab

This redis runs with protected mode enabled so gitlab is not able to communicate without setting a password. Either implement sameersbn/docker-gitlab#1453 or disable protected mode on start with --protected-mode no.

Redis::CommandError: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

cc @sameersbn

add USERMAP_UID and USERMAP_GID

Similar to doing this for some of your other docker containers, add the ability to set the uid to avoid collisions with the host user ids. Thanks!

REDIS_PASSWORD

docker-compose.yml file inside how to set REDIS_PASSWORD

Replace repo with other redis image

I've spent several days building a complete new redis image.
I would to request an evaluation from you, to see if we can use this as the basic redis image instead of sameersbn/docker-redis.

Source repository:

Both source repositories are the same.

Overview:

  • alpine:3.4
  • S6-Overlay
  • redis:3.2.5
  • master / slave support
  • full sentinel support (optional, can be activated from docker-compose)
  • full docker support for master / slave / sentinel
  • USERMAP_UID/GID support which was requested with an issue on your repo.
  • ability to run either redis-server or redis-sentinel or both within the same image.

For more information about sentinel: https://redis.io/topics/sentinel

I've thoroughly tested the master with multiple slaves with sentinel, automatic failover etc..., everything is working.

Also everything is documented within the README and I've provided 7 docker-compose examples, see the readme for more information.

I really hope you like it, and are willing to evaluate it and look at the possiblity to either reference it within docker-gitlab or fork my github repo.

Automated build is 404

Hi @sameersbn - Looks like something broke on docker hub

Unable to pull the image, and browsing to the docker hub registry page for this image gives a 404

Update

Hello,
Is it possible to update to redis 4.0.9 with this container ?

*** FATAL CONFIG FILE ERROR ***

Building the latest commit using

docker build -t redis .

and printing the version of redis

docker run redis redis-server --version

I get following error message:

Starting redis-server...
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 709
>>> 'version'
Bad directive or wrong number of arguments

Version update

Redis is up to version 6? any chance for an upgrade to this image?

WARNING overcommit_memory is set to 0

I'm getting this warning when I start this for my gitlab container

# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Is there anything to be of concern?

Your Redis version 4.0.9 is not supported anymore. Update your Redis server to a version >= 5.0.0

When upgrading sameersbn/gitlab to 14.6, and running a rake task to check the installation /sbin/entrypoint.sh app:rake gitlab:check SANITIZE=true, the following error is reported:

Redis version >= 5.0.0? ... no
  Try fixing it:
  Your Redis version 4.0.9 is not supported anymore. Update your Redis server to a version >= 5.0.0
  For more information see:
  doc/administration/redis/index.html#redis-replication-and-failover-using-the-non-bundled-redis
  Please fix the error above and rerun the checks.

The sameersbn/redis image is at 4.0.9-3 - is there any update to 5.x planned, or can another redis image be dropped in place?

`EXTRA_ARGS` not taking effect

I'm using docker compose and can't seem to get EXTRA_ARGS to take effect, for example:

version: "3"

services:
  redis:
    image: redis:7
    environment:
      EXTRA_ARGS: --loglevel warning

produces a startup log like

redis-1  | 1:C 05 Dec 2022 11:16:28.739 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1  | 1:C 05 Dec 2022 11:16:28.739 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1  | 1:C 05 Dec 2022 11:16:28.739 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-1  | 1:M 05 Dec 2022 11:16:28.740 * monotonic clock: POSIX clock_gettime
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * Running mode=standalone, port=6379.
redis-1  | 1:M 05 Dec 2022 11:16:28.741 # Server initialized
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * Loading RDB produced by version 7.0.5
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * RDB age 2 seconds
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * RDB memory usage when created 0.87 Mb
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * Done loading RDB, keys loaded: 0, keys expired: 0.
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * DB loaded from disk: 0.000 seconds
redis-1  | 1:M 05 Dec 2022 11:16:28.741 * Ready to accept connections

If I put the argument into command, it works as expected:

version: "3"

services:
  redis:
    image: redis:7
    command: --loglevel warning

The startup log with that is reduced as expected:

redis-1  | 1:C 05 Dec 2022 11:16:41.963 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1  | 1:C 05 Dec 2022 11:16:41.963 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1  | 1:C 05 Dec 2022 11:16:41.963 # Configuration loaded
redis-1  | 1:M 05 Dec 2022 11:16:41.964 # Server initialized

Is it a bug or am I just using EXTRA_ARGS incorrectly? I couldn't find any documentation about it in this repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.