In this challenge, you'll practice running arbitrary commands using off-the-shelf container images.
When invoked without any arguments, the docker run redis
command will start a redis
server in a container.
However, the redis
image also includes the redis-cli
executable,
which can be used to interact with any Redis server instance
(not necessarily the one running in the same container).
This makes a redis
container a handy way to run redis-cli
without installing it on your machine.
But only if you know how to override its default command ๐
Run redis-cli
with the --version
flag in a redis
container:
Hint 1 ๐ก
Docker designed containers in such a way that they can be run without any additional arguments by default.
For instance, docker run redis
will start a redis
process in a container,
because the redis
image has a default redis-server
command
defined in its Dockerfile:
FROM ...some base image...
RUN ..install redis...
# Run the redis-server command by default
CMD ["redis-server"]
However, oftentimes container images include more than one executable file, and you may want to run a container using other than the default command and/or pass some arguments to it.
Luckily, the docker run
command is flexible enough to support this:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Level up your Server Side game โ Join 10,000 engineers who receive insightful learning materials straight to their inbox