I am working on a Python-Flask project that has two separate docker containers for the web app and the postgres database. I want to start using rq and redis with the web app, so I added a docker container that holds the redis server. When I tried to ping the redis container from the web app container, I wasn't able to use redis-cli
. Redis is installed in the web app container. Why can't I use redis-cli
from the web app container?
When I ping the redis server from within the redis container, the response indicates that the server is up.
docker exec -it MyApp_redis_1 redis-cli ping
PONG
But, when I attempt to ping the redis server from within the web app container, I can't even use redis-cli. I ran pip freeze
within the web container and confirmed that redis==3.2.1
is installed. Still, I get the below error message
docker exec -it MyApp_web_1 redis-cli ping
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"redis-cli\": executable file not found in $PATH": unknown
I also get an error message when I attempt to use redis-cli
from a shell in the web app container:
/usr/src/app/MyApp$ redis-cli ping
bash: redis-cli: command not found
Why can't I use redis-cli from within a docker container that has redis installed?
Here is an excerpt from my docker-compose.yml
file:
version: "3"
services:
redis:
restart: always
image: redis:5.0.5
command: ["redis-server", "--appendonly", "yes"]
hostname: redis
web:
restart: always
build:
context: .
args:
- DOCKER_BUILD_ENV
dockerfile: ./dockerfiles/web/Dockerfile
environment:
****variables that I won't put on StackOverflow****
volumes:
- ./MyApp/:/usr/src/app/MyApp/:z
links:
- postgres:postgres
- redis:redis
expose:
- "3000"
command: scripts/entrypoint.sh
ports:
- "3000:3000"
Thanks for reading! (If needed, I can also share my Dockerfile.)