docker run --restart=always --log-opt max-size=100m --log-opt max-file=2 -p 6379:6379 --name myredis -v /home/redis/myredis/myredis.conf:/etc/redis/redis.conf -v /home/redis/myredis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass 000415
myredis docker exec -it myredis redis-cli
127.0.0.1:6379> get s1
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth yourpwd
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "yourpwd"
127.0.0.1:6379>
Simeple way
To run Redis on Docker on your Mac, you can follow these steps:
- Install Docker on your Mac.
- Open a terminal window.
- Run the following command to pull the latest Redis image from Docker Hub:
- Run the following command to create a new Docker container and start the Redis server:
docker run -d -p 6379:6379 redis
# --name give a name for the instance
docker run --name some-redis -d redis
The -d
flag tells Docker to run the container in detached mode, so it will not appear in the terminal output. The -p 6379:6379
flag tells Docker to map port 6379 on the Docker host to port 6379 on the Docker container. This will allow you to connect to the Redis server from your Mac using the standard Redis client.
- To verify that the Redis server is running, you can run the following command:
docker ps
This will list all of the Docker containers that are running on your Mac. You should see a line that looks like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 35213590687c redis "docker-entrypoint.sh …" 5 seconds ago Up 4 seconds 6379/tcp redis
- To connect to the Redis server from your Mac, you can use the Redis client. For example, to list all of the keys in the Redis database, you can run the following command:
redis-cli -h localhost -p 6379
This will connect to the Redis server on your Mac and list all of the keys in the database.
Refer Link:
https://www.docker.com/blog/how-to-use-the-redis-docker-official-image/