Below steps are running on MacOS. It might now work if you're using Windows OS.
Run redis docker image
>> docker run --rm -ti --name test-redis -p 6379:6379 redis:6.2-rc3-alpine1:C20Feb202119:39:26.881# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1:C20Feb202119:39:26.881# Redis version=6.1.242, bits=64, commit=00000000, modified=0, pid=1, just started1:C 20 Feb 2021 19:39:26.881 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M20Feb202119:39:26.883*monotonicclock:POSIXclock_gettime_.__.-``__''-.__.-```. `_.''-._Redis6.1.242 (00000000/0) 64 bit.-``.-```. ```\/_.,_''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-'|PID:1 `-._`-._ `-./_.-' _.-'|`-._`-._`-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-'|`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-'`-._ `-.__.-' _.-'`-.__.-' `-.__.-'1:M20Feb202119:39:26.885# Server initialized1:M 20 Feb 2021 19:39:26.885 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memor
y=1' to /etc/sysctl.conf and then reboot or run the command 'sysctlvm.overcommit_memory=1' for this to take effect.1:M 20 Feb 2021 19:39:26.885 * Ready to accept connections
Check running container
>> docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ccc47d8fe03e redis:6.2-rc3-alpine "docker-entrypoint.s…" 38 seconds ago Up 37 seconds 0.0.0.0:6379->6379/tcp test-redis
Attach another processor to open console in the container
importredis.clients.jedis.Jedis;publicclassRedisTest {publicstaticvoidmain(String[] args){//Connecting to Redis server on localhostJedis jedis =newJedis("localhost");System.out.println("Connection to server sucessfully");//check whether server is running or notSystem.out.println("Server is running: "+jedis.ping()); }}