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

后端 未结 4 1411
无人共我
无人共我 2021-02-05 02:03

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

redis:  
  image: redis
  ports:
    - \"6379\"

I guess it\'s using

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 02:36

    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.

提交回复
热议问题