why is "docker run" used to connect to redis? Trying to understand what's happening here:
root@mordor:~# 
root@mordor:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@mordor:~# 
root@mordor:~# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
10d38d6f1fa1        bridge              bridge              local
5b5fde2dd7cc        foo                 bridge              local
1a7946d0b10c        host                host                local
0cbbb6d4f486        none                null                local
root@mordor:~# 
root@mordor:~# docker run --name rd --network foo -d redis redis-server --appendonly yes
ea782770bcff816a642bc700abd2fadd524e3eeca10820e4c158ae4e72eda139
root@mordor:~# 
root@mordor:~# docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
ea782770bcff        redis               &quot;docker-entrypoint.s…&quot;   42 seconds ago      Up 40 seconds       6379/tcp            rd
root@mordor:~# 
root@mordor:~# docker run -it --network foo --rm redis redis-cli -h rd
rd:6379&gt; 
rd:6379&gt; ping
PONG
rd:6379&gt; 
rd:6379&gt; set foo bar
OK
rd:6379&gt; 
rd:6379&gt; get foo
&quot;bar&quot;
rd:6379&gt; 
rd:6379&gt; keys *
1) &quot;foo&quot;
rd:6379&gt; 

I can see how to spin up the community version of redis, I only added the foo network.  But why is the connection with run rather than exec?
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/