Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

Docker-compose , anyway to specify a redis.conf file?

my redis container is defined as he standard image in my docker_compose.yml

redis:  
  image: redis
  ports:
    - "6379"

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?

thanks for any trick...

question from:https://stackoverflow.com/questions/30547274/docker-compose-anyway-to-specify-a-redis-conf-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"

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/

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...