Docker-compose,无论如何要指定redis.conf文件? [英] Docker-compose , anyway to specify a redis.conf file?
问题描述
我的redis容器被定义为docker_compose.yml中的标准映像
my redis container is defined as he standard image in my docker_compose.yml
redis:
image: redis
ports:
- "6379"
我猜它正在使用类似在本地主机
上绑定到Redis我需要将其绑定到0.0.0.0,是否仍然需要添加本地redis.conf文件来更改绑定并让docker-compose知道呢?
I guess it's using standard settings like binding to Redis at localhost I need to bind it to 0.0.0.0, is there anyway to add a local redis.conf file to change the binding and let docker-compose knows it?
感谢您的技巧...
推荐答案
是的。只需将您的 redis.conf
挂载到默认卷上即可:
Yes. Just mount your redis.conf
over the default with a volume:
redis:
image: redis
volumes:
- ./redis.conf:/usr/local/etc/redis/redis.conf
ports:
- "6379"
或者,基于redis映像创建新映像,并复制conf文件。Full指示位于: https://registry.hub.docker.com/_/redis/
Alternatively, create a new image based on the redis image with your conf file copied in. Full instructions are at: https://registry.hub.docker.com/_/redis/
但是,默认情况下,redis图像确实绑定到 0.0.0.0
。要从主机访问它,您需要通过使用 docker ps
或使用Docker映射到您要找到的主机的端口。 docker port
命令,然后可以在 localhost:32678
处访问它,其中32678是映射的端口。或者,您可以在 docker-compose.yml
中指定要映射的特定端口。
However, the redis image does bind to 0.0.0.0
by default. To access it from the host, you need to use the port that Docker has mapped to the host for you which you find by using docker ps
or the docker port
command, you can then access it at localhost:32678
where 32678 is the mapped port. Alternatively, you can specify a specific port to map to in the docker-compose.yml
.
对于Docker来说是新手,如果您从使用原始Docker命令开始而不是从Compose开始,这可能会更有意义。
As you seem to be new to Docker, this might all make a bit more sense if you start by using raw Docker commands rather than starting with Compose.
这篇关于Docker-compose,无论如何要指定redis.conf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!