If you simply execute docker run -d redis
, you will get a redis instance. But, it should not be used in production environment, reasons are:
Here is an example command:
docker run --name dk_redis -d -p 16379:6379 redis redis-server \
--requirepass pass1 \
--maxmemory 512mb
requirepass
argument set the password. Please replace pass1
with your actual password.maxmemory
argument set the maximum memory that redis can take up.Access inside the container:
docker exec -it dk_redis redis-cli -a pass1
Access outside the container:
redis-cli -p 16379 -a pass1
We set --maxmemory 512mb
earlier, now let's check the effect:
docker exec -it dk_redis redis-cli -a pass1 CONFIG GET maxmemory
The output will be like:
1) "maxmemory"
2) "536870912"