version: '3.8'
services:
  cache:
    image: redis:6.2-alpine
    restart: always
    ports:
      - '6379:6379'
    command: redis-server --save 20 1 --loglevel warning --requirepass this_is_password
    volumes: 
      - cache:/data
volumes:
  cache:
    driver: local

以上是redis在docker下运行时的docker.yml文件示例。