Redis在Docker容器中未保存数据。

huangapple go评论78阅读模式
英文:

Redis is not saving data in the docker container

问题

我有这个docker-compose.yml文件的代码:

version: '3.3'

services:
  redis:
    container_name: redis
    image: 'redis:latest'
    environment:
      X_REDIS_PORT: ${REDIS_PORT}
    ports:
      - ${REDIS_PORT}:${REDIS_PORT}
    volumes:
      - redis:/data

networks:
  app_network:
    external: true
    driver: bridge

volumes:
  postgres:
  pgadmin:
  supertoken:
  redis:

我想要将缓存数据保存在redis容器内,但实际上它保存在我的本地机器上。如何更改这种行为?

英文:

I have this docker-compose.yml file code:

version: '3.3'

services:
  redis:
    container_name: redis
    image: 'redis:latest'
    environment:
      X_REDIS_PORT: ${REDIS_PORT}
    ports:
      - ${REDIS_PORT}:${REDIS_PORT}
    volumes:
      - redis:/data

    networks:
      app_network:
            external: true
            driver: bridge
    volumes:
      postgres:
      pgadmin:
      supertoken:
      redis:

I want to save the cached data inside of the redis container but it is not getting saved in the container instead it gets saved on my local machine.
How to change this behaviour?

答案1

得分: 1

检查你的卷,

docker volume inspect redis

挂载点是 /var/lib/docker/volumes/,检查 Redis 卷的数据。

我使用文件夹,我的 GitHub 存储库 中有一个示例,

    volumes:
      - ./data:/data
英文:

inspect your volume,

docker volume inspect redis

the mountpoint is /var/lib/docker/volumes/, check the redis volumes data.

I use folder,there is a demo in my github repo,

    volumes:
      - ./data:/data

huangapple
  • 本文由 发表于 2023年1月6日 14:46:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75027792.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定