I enrolled in the just concluded Redislabs course.
I didn't want to install redis locally because of storage contraints on my computer for the assignments and exams, and set to doing it all using Docker containers.
I document the steps for my setup for the courseware. The course also provides this image for the courseware on Docker Hub.
Start up server using host network mode.
Redis listens on port 6379 on the host.
docker run --rm --name redis --network host redis:latest
Test connection to the redis server using the Redis CLI client
docker run --rm -it --network host redis redis-cli -p 6379
docker run --rm -it -p 127.0.0.1:8888:8888 jupyter/base-notebook start.sh jupyter notebook --ip='*' --port=8888
You must pass the ip option as a wildcard. Otherwise the notebook server would default to listening on localhost. That's documented here.
This is needed to have the notebook connect to services running external to the notebook container.
redis
is one example in this case.
docker inspect $(docker ps -f "ancestor=jupyter/base-notebook" -f "publish=8888" --format "{{.ID}}") --format "{{.NetworkSettings.Networks.bridge.Gateway}}"
pip install redis
import redis
key = 'foo'
client = redis.Redis('replace-with-network-gateway-ip-address')
client.set(key, 1.5)
result = client.get(key)
Exit the running containers with key combination Ctrl+C
.
Then cleanup the images.
docker rmi jupyter/base-notebook redis