Say, we have a container running Redis.
docker run redis
To execute the Redis CLI and access the Redis server within the container, we can execute a command that relays our given command to the container.
docker exec -it container-id redis-cli
What is happening here?
exec
is the command for running a command within a container.- We’re telling Docker to tell the container that we want to provide input to the container by passing the
-it
flag. - We’re telling Docker to tell the container that we want to execute
redis-cli
.