why is "docker run" used to connect to redis?
In short, docker exec is used to operate an already-running container, while docker run -it starts a new container interactively.
When you ran docker run -it --network foo --rm redis redis-cli -h rd you created a 2nd container, this time using the redis-cli image, which was used to query your running redis container.
Were you to repeat the steps you took, and then open another terminal and run docker container ls, you would see two running containers.
Reference: https://spin.atomicobject.com/2018/10/04/docker-command-line/